index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <!-- 商家中心 -->
  2. <template>
  3. <view class="merchant-wrap">
  4. <view class="shopinfo-box">
  5. <!-- 标题栏 -->
  6. <shopro-navbar
  7. back-icon-color="#fff"
  8. :background="{ background: `url(${$IMG_URL}/imgs/user/shop_headbg.png) no-repeat top center / 100% auto`}"
  9. :backTextStyle="{ color: '#fff', fontSize: '36rpx', fontWeight: '500' }"
  10. backText="商家中心"
  11. ></shopro-navbar>
  12. <!-- 商家信息 -->
  13. <view class="user-head u-flex u-row-between">
  14. <view class="shop-info">
  15. <view class="u-flex u-m-b-10" @tap="goStoreList">
  16. <text class="shop-title u-m-r-20">{{ storeDetail.name }}</text>
  17. <text class="iconfont icon-xiala"></text>
  18. </view>
  19. <view class="shop-address u-ellipsis-2" @tap="jump('/pages/app/merchant/info')">
  20. {{ storeDetail.province_name || '' }}{{ storeDetail.city_name || '' }}{{ storeDetail.area_name || '' }}{{ storeDetail.address || '' }}
  21. </view>
  22. </view>
  23. <button @tap="$Router.pushTab('/pages/index/user')" class="u-reset-button merchant-btn">切换个人版</button>
  24. </view>
  25. </view>
  26. <!-- 核销卡片 -->
  27. <view class="info-card-box u-flex u-row-between">
  28. <view class="info-card">
  29. <image class="card-bg" :src="$IMG_URL + '/imgs/user/shop_info.png'" mode="aspectFill"></image>
  30. <view class="card-content u-flex-col">
  31. <view class="card-title">输码核销</view>
  32. <view class="u-flex card-detail-box" @tap="showInputModal = true">
  33. <text class="iconfont icon-21shuru icon-color1"></text>
  34. <text class="icon-color1 u-m-l-20">输码</text>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="info-card" @tap="scanCode">
  39. <image class="card-bg" :src="$IMG_URL + '/imgs/user/shop_qrcode.png'" mode="aspectFill"></image>
  40. <view class="card-content u-flex-col">
  41. <view class="card-title">扫码核销</view>
  42. <view class="u-flex card-detail-box">
  43. <text class="iconfont icon-icon-test1 icon-color2"></text>
  44. <text class="icon-color2 u-m-l-20">扫码</text>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="cancel-shop-box">
  50. <!-- 筛选框 -->
  51. <view class="cancel-nav u-flex">
  52. <u-dropdown ref="uDropdown" activeColor="#4cb89d" :borderBottom="false">
  53. <u-dropdown-item v-model="filter1Value" @change="changeFilter1" :title="filter1Label" :options="filterList1"></u-dropdown-item>
  54. <u-dropdown-item v-model="filter2Value" @change="changeFilter2" :title="filter2Label" :options="filterList2"></u-dropdown-item>
  55. </u-dropdown>
  56. </view>
  57. <!-- 销量 -->
  58. <view class="sales-volume-box u-flex u-row-between u-p-30">
  59. <view class="sales-volume u-flex u-row-center u-col-center">订单量(单):{{ orderInfo.total_num || 0 }}</view>
  60. <view class="sales-volume u-flex u-row-center u-col-center">交易额(元):{{ orderInfo.total_money || 0 }}</view>
  61. </view>
  62. </view>
  63. <!-- 订单列表 -->
  64. <view class="order-list" v-for="order in storeOrderList" :key="order.order_sn" @tap="jump('/pages/app/merchant/detail', { orderId: order.id })">
  65. <view class="order-head u-flex u-row-between">
  66. <text class="no">订单编号:{{ order.order_sn }}</text>
  67. <text class="state">{{ order.status_name }}</text>
  68. </view>
  69. <view class="goods-order" v-for="item in order.item" :key="item.id">
  70. <shopro-mini-card :title="item.goods_title" :image="item.goods_image">
  71. <template #describe>
  72. <view class="order-sku u-ellipsis-1">
  73. <text class="order-num">数量:{{ item.goods_num || 0 }};</text>
  74. {{ item.goods_sku_text ? item.goods_sku_text : '' }}
  75. </view>
  76. </template>
  77. <template #cardBottom>
  78. <view class="order-price-box u-flex ">
  79. <text class="order-price font-OPPOSANS">¥{{ item.goods_price || 0 }}</text>
  80. <button class="u-reset-button status-btn" v-if="item.status_name">{{ item.status_name }}</button>
  81. </view>
  82. </template>
  83. </shopro-mini-card>
  84. </view>
  85. <view class="order-bottom u-flex">
  86. <view class="u-flex u-m-r-30" v-if="reduceAdd(order.item, 'discount_fee')">
  87. <text class="total-price-title">优惠:</text>
  88. <text class="total-price">{{ reduceAdd(order.item, 'discount_fee') }}</text>
  89. </view>
  90. <view class="u-flex">
  91. <text class="total-price-title">实付款:</text>
  92. <text class="total-price">{{ reduceAdd(order.item, 'pay_price') }}</text>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 置空页 -->
  97. <u-empty :show="isEmpty" margin-top="160" mode="list"></u-empty>
  98. <!-- 更多 -->
  99. <u-loadmore v-if="storeOrderList.length" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
  100. <!-- 日期选择 -->
  101. <u-calendar
  102. v-model="showCalendar"
  103. safeAreaInsetBottom
  104. mode="range"
  105. start-text="开始"
  106. end-text="结束"
  107. range-color="#4CB89D"
  108. range-bg-color="rgba(76,184,157,0.13)"
  109. active-bg-color="#4CB89D"
  110. :customStyle="{ background: 'linear-gradient(90deg, #4cb89d, #4CB89D)', boxShadow: '0 7rpx 11rpx 2rpx rgba(4cb89d, 0.34)' }"
  111. btnType="success"
  112. @change="selDate"
  113. ></u-calendar>
  114. <!-- 输码弹窗 -->
  115. <u-popup v-model="showInputModal" mode="center" :closeable="true" close-icon-pos="top-left" border-radius="20">
  116. <view class="modal-box u-flex-col u-col-center">
  117. <view class="modal-head u-flex-col u-col-center">
  118. <image class="modal-head-img" :src="$IMG_URL + '/imgs/modal/store_check.png'" mode=""></image>
  119. <text class="modal-head-title">输码核销</text>
  120. </view>
  121. <input class="inp" type="number" v-model="qrcode" placeholder="在此输入核销码" placeholder-class="pl-inp" />
  122. <button class="u-reset-button post-btn" @tap="onConfirm">核销</button>
  123. </view>
  124. </u-popup>
  125. <!-- 禁用弹窗 -->
  126. <u-modal
  127. ref="uModal"
  128. v-model="showModal"
  129. :show-cancel-button="false"
  130. confirm-color="#999"
  131. confirm-text="返回"
  132. content="当前门店已被禁用,是否返回重新选择?"
  133. title="提示"
  134. @confirm="$Router.back()"
  135. ></u-modal>
  136. </view>
  137. </template>
  138. <script>
  139. import { mapMutations, mapActions, mapState } from 'vuex';
  140. import Auth from '@/shopro/permission/index.js';
  141. export default {
  142. components: {},
  143. data() {
  144. return {
  145. isEmpty: false,
  146. showModal: false,
  147. // 筛选
  148. filter1: 'today',
  149. filter1Value: 0,
  150. filter1Label: '今日',
  151. filterList1: [
  152. { label: '今日', value: 0, parmas: 'today' },
  153. { label: '昨日', value: 1, parmas: 'yesterday' },
  154. { label: '本周', value: 2, parmas: 'week' },
  155. { label: '本月', value: 3, parmas: 'month' },
  156. { label: '自定义', value: 4, parmas: 'custom' }
  157. ],
  158. filter2: 'all',
  159. filter2Value: 0,
  160. filter2Label: '全部',
  161. filterList2: [
  162. { label: '全部', value: 0, parmas: 'all' },
  163. { label: '待发货', value: 1, parmas: 'nosend' },
  164. { label: '待完成', value: 2, parmas: 'noget' },
  165. { label: '已完成', value: 3, parmas: 'finish' }
  166. ],
  167. custom: [], //自定义日期
  168. storeOrderList: [], //订单商品列表
  169. orderInfo: {}, //订单统计信息
  170. storeDetail: {}, //门店信息
  171. cancelType: '', //核销分类
  172. scanCodes: [], //扫码内容。
  173. showInputModal: false, //输码核销
  174. qrcode: '', //输码
  175. showCalendar: false, //日期选择
  176. loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
  177. currentPage: 1,
  178. lastPage: 1
  179. };
  180. },
  181. computed: {},
  182. onLoad(options) {
  183. options && options.storeId && uni.setStorageSync('storeId', options.storeId);
  184. this.getStoreDetail();
  185. },
  186. onShow() {
  187. this.currentPage = 1;
  188. this.lastPage = 1;
  189. this.storeOrderList = [];
  190. this.getStoreOrder();
  191. },
  192. onPullDownRefresh() {
  193. this.currentPage = 1;
  194. this.lastPage = 1;
  195. this.storeOrderList = [];
  196. this.getStoreOrder();
  197. },
  198. onReachBottom() {
  199. if (this.currentPage < this.lastPage) {
  200. this.currentPage += 1;
  201. this.getStoreOrder();
  202. }
  203. },
  204. methods: {
  205. jump(path, query) {
  206. this.$Router.push({
  207. path: path,
  208. query: query
  209. });
  210. },
  211. /**
  212. * 累加某字段值
  213. * @param {Array} list - 源数据
  214. * @param {String} key - 键名
  215. */
  216. reduceAdd(list, key) {
  217. return list.reduce((pre, cur) => (pre += Number(cur[key])), 0);
  218. },
  219. // 筛选
  220. changeFilter1(e) {
  221. if (e === 4) {
  222. this.showCalendar = true;
  223. } else {
  224. this.filter1 = this.filterList1[e].parmas;
  225. this.filter1Label = this.filterList1[e].label;
  226. this.onFilter();
  227. }
  228. },
  229. changeFilter2(e) {
  230. this.filter2 = this.filterList2[e].parmas;
  231. this.filter2Label = this.filterList2[e].label;
  232. this.onFilter();
  233. },
  234. // 选择门店
  235. goStoreList() {
  236. this.$Router.replace({
  237. path: '/pages/app/merchant/list'
  238. });
  239. },
  240. // 获取门店信息
  241. getStoreDetail() {
  242. let that = this;
  243. that.$http('store.info', {
  244. store_id: uni.getStorageSync('storeId')
  245. }).then(res => {
  246. if (res.code === 1) {
  247. that.storeDetail = res.data;
  248. } else {
  249. uni.removeStorageSync('storeId');
  250. that.showModal = true;
  251. }
  252. });
  253. },
  254. // 扫码
  255. async scanCode() {
  256. let platform = this.$platform.get();
  257. let authState = await new Auth('camera').check();
  258. // #ifdef H5
  259. if (platform === 'H5') {
  260. this.$u.toast('普通浏览器不支持扫码功能,请使用小程序或微信内浏览器');
  261. } else {
  262. this.$wxsdk.scanQRCode(res => {
  263. this.scanCodes = res.resultStr.split(',');
  264. this.postOrderConfirm();
  265. });
  266. }
  267. // #endif
  268. // #ifndef H5
  269. authState &&
  270. uni.scanCode({
  271. success: res => {
  272. this.scanCodes = res.result.split(',');
  273. this.postOrderConfirm();
  274. },
  275. fail: err => {
  276. console.log(err);
  277. }
  278. });
  279. // #endif
  280. },
  281. // 输码
  282. onConfirm() {
  283. this.showInputModal = false;
  284. this.scanCodes = [];
  285. this.scanCodes.push(this.qrcode);
  286. this.postOrderConfirm();
  287. },
  288. // 核销
  289. postOrderConfirm() {
  290. let that = this;
  291. that.$http(
  292. 'store.orderConfirm',
  293. {
  294. codes: that.scanCodes,
  295. store_id: uni.getStorageSync('storeId')
  296. },
  297. '核销中...'
  298. ).then(res => {
  299. uni.vibrateLong({
  300. success: () => {
  301. that.$u.toast(res.msg);
  302. }
  303. });
  304. if (res.code === 1) {
  305. that.$u.toast(res.msg);
  306. that.scanCodes = [];
  307. that.storeOrderList = [];
  308. that.qrcode = '';
  309. that.getStoreOrder();
  310. }
  311. });
  312. },
  313. // 门店订单列表
  314. getStoreOrder() {
  315. let that = this;
  316. that.loadStatus = 'loading';
  317. that.$http(
  318. 'store.order',
  319. {
  320. date_type: that.filter1,
  321. date: that.custom,
  322. type: that.filter2,
  323. page: that.currentPage,
  324. store_id: uni.getStorageSync('storeId')
  325. },
  326. '加载中...'
  327. ).then(res => {
  328. uni.stopPullDownRefresh();
  329. if (res.code == 1) {
  330. that.storeOrderList = [...that.storeOrderList, ...res.data.result.data];
  331. that.isEmpty = !that.storeOrderList.length;
  332. that.orderInfo = res.data;
  333. that.lastPage = res.data.result.last_page;
  334. that.loadStatus = that.currentPage < res.data.result.last_page ? 'loadmore' : 'nomore';
  335. }
  336. });
  337. },
  338. // 选择日期
  339. selDate(e) {
  340. this.custom = [];
  341. this.custom.push(e.startDate);
  342. this.custom.push(e.endDate);
  343. this.isShowDropDown = false;
  344. this.filter1Label = `${e.startDate.replace(/-/g, ':')}-${e.endDate.replace(/-/g, ':')}`;
  345. this.onFilter();
  346. },
  347. // 选择筛选
  348. onFilter(val, title) {
  349. this.storeOrderList = [];
  350. this.currentPage = 1;
  351. this.getStoreOrder();
  352. }
  353. }
  354. };
  355. </script>
  356. <style lang="scss">
  357. // 遮罩
  358. .mask {
  359. width: 100%;
  360. height: 100%;
  361. position: fixed;
  362. z-index: 20;
  363. }
  364. // 商户信息
  365. .shopinfo-box {
  366. background: url($IMG_URL+'/imgs/user/shop_headbg.png') no-repeat;
  367. background-size: 100% 100%;
  368. height: 320rpx;
  369. .user-head {
  370. padding-top: 10rpx;
  371. .shop-info {
  372. padding-left: 30rpx;
  373. .shop-title {
  374. font-size: 34rpx;
  375. font-weight: bold;
  376. color: rgba(255, 255, 255, 1);
  377. }
  378. .icon-xiala {
  379. font-size: 34rpx;
  380. color: rgba(255, 255, 255, 1);
  381. }
  382. .shop-address {
  383. font-size: 28rpx;
  384. font-weight: 500;
  385. color: rgba(255, 255, 255, 1);
  386. width: 540rpx;
  387. }
  388. }
  389. .merchant-btn {
  390. padding: 0;
  391. width: 136rpx;
  392. line-height: 46rpx;
  393. background: rgba(255, 255, 255, 1);
  394. border-radius: 23rpx 0px 0px 23rpx;
  395. font-size: 20rpx;
  396. font-weight: 500;
  397. color: #3eb49c;
  398. }
  399. }
  400. }
  401. // 卡片
  402. .info-card-box {
  403. background-color: #fff;
  404. padding: 30rpx 20rpx;
  405. .info-card {
  406. position: relative;
  407. width: 350rpx;
  408. height: 165rpx;
  409. border-radius: 10rpx;
  410. overflow: hidden;
  411. .card-bg {
  412. width: 100%;
  413. height: 100%;
  414. }
  415. .card-content {
  416. position: absolute;
  417. width: 100%;
  418. height: 100%;
  419. z-index: 3;
  420. top: 0;
  421. left: 0;
  422. padding: 30rpx 0 0 30rpx;
  423. .card-title {
  424. font-size: 28rpx;
  425. font-weight: bold;
  426. color: rgba(255, 255, 255, 1);
  427. }
  428. .card-detail-box {
  429. padding: 10rpx 20rpx;
  430. height: 45rpx;
  431. background: rgba(255, 255, 255, 1);
  432. width: 150rpx;
  433. border-radius: 23rpx;
  434. margin-top: 20rpx;
  435. .card-detail {
  436. font-size: 22rpx;
  437. font-weight: 500;
  438. }
  439. .icon-color1 {
  440. color: #00b6ce;
  441. font-size: 24rpx;
  442. }
  443. .icon-color2 {
  444. color: #0f98f9;
  445. font-size: 24rpx;
  446. }
  447. }
  448. }
  449. }
  450. }
  451. // 核销nav
  452. .cancel-nav {
  453. background: #fff;
  454. margin: 10rpx 0 0;
  455. position: relative;
  456. z-index: 22;
  457. }
  458. // 销量
  459. .sales-volume-box {
  460. background-color: #fff;
  461. .sales-volume {
  462. width: 338rpx;
  463. height: 72rpx;
  464. background: rgba(76, 184, 157, 0.06);
  465. border: 1rpx solid rgba(185, 227, 217, 1);
  466. border-radius: 10rpx;
  467. font-size: 24rpx;
  468. font-weight: 400;
  469. color: rgba(76, 184, 157, 1);
  470. }
  471. }
  472. // 输码弹窗
  473. .modal-box {
  474. background: #fff;
  475. width: 610rpx;
  476. margin: 0 auto;
  477. border-radius: 20rpx;
  478. .modal-head {
  479. width: 100%;
  480. .modal-head-img {
  481. width: 100%;
  482. height: 213rpx;
  483. }
  484. .modal-head-title {
  485. font-size: 35rpx;
  486. font-weight: bold;
  487. color: #343434;
  488. line-height: 42rpx;
  489. }
  490. }
  491. .inp {
  492. width: 501rpx;
  493. height: 78rpx;
  494. border: 1rpx solid #e5e5e5;
  495. margin: 60rpx auto 40rpx;
  496. font-size: 28rpx;
  497. font-weight: 400;
  498. color: #6d5028;
  499. padding-left: 20rpx;
  500. .pl-inp {
  501. color: #9a9a9a;
  502. }
  503. }
  504. .post-btn {
  505. width: 492rpx;
  506. line-height: 70rpx;
  507. background: linear-gradient(90deg, #2eae9c, #6cc29f);
  508. box-shadow: 0px 7rpx 6rpx 0px rgba(#6cc29f, 0.22);
  509. border-radius: 35rpx;
  510. font-size: 28rpx;
  511. font-weight: 500;
  512. color: rgba(255, 255, 255, 1);
  513. padding: 0;
  514. margin-bottom: 60rpx;
  515. }
  516. }
  517. // 订单列表
  518. .order-list {
  519. background: #fff;
  520. margin: 20rpx 0;
  521. padding: 0 20rpx;
  522. .order-bottom {
  523. justify-content: flex-end;
  524. height: 80rpx;
  525. padding: 0 20rpx;
  526. .total-price-title {
  527. color: #999999;
  528. font-size: 24rpx;
  529. }
  530. .total-price {
  531. color: #333;
  532. font-size: 26rpx;
  533. &::before {
  534. content: '¥';
  535. font-size: 20rpx;
  536. }
  537. }
  538. }
  539. .order-head {
  540. padding: 0 25rpx;
  541. height: 77rpx;
  542. border-bottom: 1rpx solid #dfdfdf;
  543. .no {
  544. font-size: 26rpx;
  545. color: #999;
  546. }
  547. .state {
  548. font-size: 26rpx;
  549. color: #a8700d;
  550. }
  551. }
  552. .goods-order {
  553. border-bottom: 1px solid rgba(223, 223, 223, 0.5);
  554. padding: 20rpx;
  555. margin-bottom: 20rpx;
  556. .order-sku {
  557. font-size: 24rpx;
  558. font-weight: 400;
  559. color: rgba(153, 153, 153, 1);
  560. width: 450rpx;
  561. margin-bottom: 20rpx;
  562. .order-num {
  563. margin-right: 10rpx;
  564. }
  565. }
  566. .order-price-box {
  567. .status-btn {
  568. height: 32rpx;
  569. border: 1rpx solid rgba(207, 169, 114, 1);
  570. border-radius: 15rpx;
  571. font-size: 20rpx;
  572. font-weight: 400;
  573. color: rgba(168, 112, 13, 1);
  574. padding: 0 10rpx;
  575. margin-left: 20rpx;
  576. background: rgba(233, 183, 102, 0.16);
  577. }
  578. .order-price {
  579. font-size: 26rpx;
  580. font-weight: 600;
  581. color: rgba(51, 51, 51, 1);
  582. }
  583. }
  584. }
  585. }
  586. </style>