index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="fixed-lt bg--w111-f5f5f5 w-full z-999 header_box" :style="{'padding-top': sysHeight + 'px'}">
  4. <view class="h-80 px-20 flex-y-center">
  5. <text class="iconfont icon-ic_leftarrow fs-40 text--w111-333" @click="goPage(3)"></text>
  6. <!-- #ifdef MP-WEIXIN -->
  7. <view class="w-460 h-58 rd-30 bg--w111-fff flex-y-center px-32 ml-20">
  8. <!-- #endif -->
  9. <!-- #ifndef MP-WEIXIN -->
  10. <view class="flex-1 h-58 rd-30 bg--w111-fff flex-y-center px-32 ml-20">
  11. <!-- #endif -->
  12. <text class="iconfont icon-ic_search fs-24 text--w111-999"></text>
  13. <input v-model="keyword" confirm-type="search" @focus="searchFocus" @confirm="inputConfirm"
  14. class="pl-18 flex-1 fs-24" placeholder="请输入商品名称" placeholder-class="text--w111-999" />
  15. </view>
  16. </view>
  17. <view class="h-100 w-full px-32 flex-between-center fs-26" v-show="!focus">
  18. <text :class="orderStatus === '' ? 'active' : ''" @click="statusClick('')">全部</text>
  19. <text :class="orderStatus === 0 ? 'active' : ''" @click="statusClick(0)">待付款</text>
  20. <text :class="orderStatus === 1 ? 'active' : ''" @click="statusClick(1)">待发货</text>
  21. <view class="relative">
  22. <text :class="orderStatus === 2 ? 'active' : ''" @click="statusClick(2)">待收货/核销</text>
  23. <uni-badge class="uni-badge-left-margin" v-if="orderData.received_count > 0" :text="orderData.received_count"></uni-badge>
  24. </view>
  25. <text :class="orderStatus === 3 ? 'active' : ''" @click="statusClick(3)">待评价</text>
  26. </view>
  27. </view>
  28. <view class="pt-32 pl-20 pr-20" :style="{'margin-top':marTop - 50 + 'px'}" v-show="focus">
  29. <view class="fs-28 text--w111-333 fw-500 lh-40rpx mb-24 acea-row row-between-wrapper">
  30. <view>历史搜索</view>
  31. <view class="iconfont icon-ic_delete text--w111-999 fs-28" @click="delHistory"></view>
  32. </view>
  33. <view class="flex flex-wrap">
  34. <text class="inline-block max-200 h-56 line1 lh-56rpx rd-28rpx bg--w111-fff px-24 fs-24 text--w111-666 text-center mr-24 mb-16"
  35. v-for="(item,index) in historyList" :key="index" @click="goSearch(item)">{{item}}</text>
  36. <text
  37. </view>
  38. </view>
  39. <view class="px-20" :style="{'margin-top':marTop + 'px'}" v-show="!focus">
  40. <view class="order_card bg--w111-fff rd-24rpx pt-32 pb-32 pl-24 pr-24"
  41. v-for="(item, index) in orderList" :key="index" @click="goOrderDetails(item.order_id)">
  42. <view class="flex-between-center">
  43. <view class="flex-y-center">
  44. <text v-if="item.pink_name"
  45. class="h-32 bg--w111-fff px-6 rd-6rpx fs-20 border_con font-num acea-row row-middle">
  46. {{item.pink_name}}</text>
  47. <text class="fs-28 lh-40rpx text--w111-333 pl-16">{{item._add_time}}</text>
  48. </view>
  49. <view class="fs-26">
  50. <view class="font-num">
  51. <text>{{item._status._title}}</text>
  52. <text v-if="item.refund.length">{{item.is_all_refund?',退款中':',部分退款中'}}</text>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="mt-26" v-if="item.cartInfo.length && item.cartInfo.length == 1">
  57. <view class="flex justify-between" v-for="(items, i) in item.cartInfo" :key="i">
  58. <view class="flex">
  59. <easy-loadimage
  60. mode="widthFix"
  61. :image-src="items.productInfo.image"
  62. width="136rpx"
  63. height="136rpx"
  64. borderRadius="16rpx"></easy-loadimage>
  65. <view class="ml-20">
  66. <view class="w-346 fs-28 text--w111-333 lh-40rpx line2"> {{items.productInfo.store_name }}
  67. </view>
  68. <view class="w-346 fs-24 text--w111-999 lh-34rpx line1 mt-12">{{items.productInfo.attrInfo.suk}}</view>
  69. </view>
  70. </view>
  71. <view>
  72. <!-- <baseMoney v-if="items.productInfo.attrInfo" :money="items.productInfo.attrInfo.price"
  73. symbolSize="20" integerSize="32" decimalSize="20" incolor="#333333" weight></baseMoney>
  74. <baseMoney v-else :money="items.productInfo.price" symbolSize="20" integerSize="32"
  75. decimalSize="20" incolor="#333333" weight></baseMoney> -->
  76. <baseMoney :money="item.pay_price" symbolSize="20" integerSize="32" decimalSize="20"
  77. incolor="#333333" weight></baseMoney>
  78. <view class="fs-24 text--w111-999 lh-34rpx text-right">共{{item.total_num}}件</view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="mt-26 relative" v-if="item.cartInfo.length && item.cartInfo.length > 1">
  83. <scroll-view scroll-x="true" class="white-nowrap vertical-middle w-560" show-scrollbar="false">
  84. <view class="inline-block mr-16" v-for="(items,i) in item.cartInfo" :key="i">
  85. <easy-loadimage
  86. mode="widthFix"
  87. :image-src="items.productInfo.image"
  88. width="136rpx"
  89. height="136rpx"
  90. borderRadius="16rpx"></easy-loadimage>
  91. </view>
  92. </scroll-view>
  93. <view class="abs-rt h-136 flex-col flex-center">
  94. <baseMoney :money="item.pay_price" symbolSize="20" integerSize="32" decimalSize="20"
  95. incolor="#333333" weight></baseMoney>
  96. <view class="fs-24 text--w111-999 lh-34rpx text-right">共{{item.total_num}}件</view>
  97. </view>
  98. </view>
  99. <view class="h-72 rd-8rpx bg--w111-f5f5f5 mt-26 px-20 flex-between-center">
  100. <view>
  101. <text class="text--w111-333 fs-26">{{item._status._title}}</text>
  102. <text class="text--w111-999 fs-26 pl-20">{{item._status._msg}}</text>
  103. </view>
  104. <text class="iconfont icon-ic_rightarrow fs-24 text--w111-999"></text>
  105. </view>
  106. <view class="mt-32 flex-between-center">
  107. <!-- <text class="fs-24 font-num" v-if="item._status._type == 0">{{item._status._msg}}</text> -->
  108. <text></text>
  109. <view class="flex">
  110. <view class="btn w-154 h-56 rd-30rpx flex-center fs-24 border_ccc"
  111. v-if="item._status._type == 0 || item._status._type == 9"
  112. @tap.stop="showModalChange(item.order_id, 3)">取消订单</view>
  113. <view class="btn w-154 h-56 rd-30rpx flex-center fs-24 bg-color text--w111-fff"
  114. v-if="item._status._type == 0" @click.stop="goPay(item.order_id)">立即支付</view>
  115. <view class="btn w-154 h-56 rd-30rpx flex-center fs-24 bg-color text--w111-fff"
  116. v-else-if="item._status._type == 3" @click.stop="goOrderDetails(item.order_id)">立即评价</view>
  117. <!-- <view class="btn w-154 h-56 rd-30rpx flex-center fs-24 bg-color text--w111-fff"
  118. v-if="item._status._type == 4" @tap.stop="showModalChange(item.order_id, 2)">删除订单</view> -->
  119. </view>
  120. </view>
  121. </view>
  122. <block v-if="orderList.length == 0 && !loading">
  123. <emptyPage title="暂无订单信息~" :src="keyword ? '/statics/images/noSearch.gif' : '/statics/images/noOrder.gif'"></emptyPage>
  124. </block>
  125. <view class="loadingicon flex-center" v-if="orderList.length > 0">
  126. <text class="loading iconfont icon-ic_Refresh" :hidden="loading == false"></text>
  127. <text class="fs-26 pb-32">{{ loadTitle }}</text>
  128. </view>
  129. </view>
  130. <!-- 确认框 -->
  131. <tuiModal
  132. :show="showModal"
  133. :title="modalTitle"
  134. :content="modalContent"
  135. :maskClosable="false"
  136. @click="handleClick"
  137. @cancel="hideModal"></tuiModal>
  138. </view>
  139. </template>
  140. <script>
  141. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  142. import {
  143. getOrderList,
  144. orderData,
  145. orderCancel,
  146. orderDel,
  147. orderPay
  148. } from '@/api/order.js';
  149. import { openOrderSubscribe } from '@/utils/SubscribeMessage.js';
  150. import home from '@/components/home';
  151. import tuiModal from "@/components/tui-modal/index.vue"
  152. import { toLogin } from '@/libs/login.js';
  153. import { mapGetters } from 'vuex';
  154. import emptyPage from '@/components/emptyPage.vue';
  155. import colors from '@/mixins/color.js';
  156. import Loading from '@/components/Loading/index.vue'
  157. export default {
  158. components: {
  159. Loading,
  160. home,
  161. emptyPage,
  162. tuiModal
  163. },
  164. mixins: [colors],
  165. data() {
  166. return {
  167. sysHeight:sysHeight,
  168. loaded: false,
  169. loading: false, //是否加载中
  170. loadend: false, //是否加载完毕
  171. loadTitle: '加载更多', //提示语
  172. orderList: [], //订单数组
  173. orderData: {}, //订单详细统计
  174. orderStatus: '', //订单状态
  175. orderType: '', //订单类型
  176. page: 1,
  177. limit: 20,
  178. pay_close: false,
  179. pay_order_id: '',
  180. totalPrice: '0',
  181. isAuto: false, //没有授权的不会自动授权
  182. isShowAuth: false, //是否隐藏授权
  183. keyword: '',
  184. marTop:0,
  185. focus:false,
  186. // 搜索历史
  187. historyList: [],
  188. // 临时搜索列表
  189. tempStorage: [],
  190. //确认模态框
  191. showModal:false,
  192. modalTitle:'',
  193. modalContent:'',
  194. modalType:0,
  195. orderId:''
  196. };
  197. },
  198. computed: {
  199. ...mapGetters(['isLogin']),
  200. fixedTop() {
  201. // #ifdef MP || APP-PLUS
  202. return this.sysHeight + 'px'
  203. // #endif
  204. return this.data
  205. // #ifndef MP
  206. return 0
  207. // #endif
  208. }
  209. },
  210. onShow() {
  211. uni.removeStorageSync('form_type_cart');
  212. this.page = 1;
  213. this.loadend = false;
  214. this.orderList = [];
  215. if (this.isLogin) {
  216. this.getFun();
  217. } else {
  218. toLogin()
  219. }
  220. },
  221. onPageScroll(object) {
  222. uni.$emit('scroll');
  223. },
  224. /**
  225. * 生命周期函数--监听页面加载
  226. */
  227. onLoad(options) {
  228. if (options.status) this.orderStatus = (options.status == undefined && options.status != 0) ? '' : parseInt(
  229. options.status);
  230. if (options.type) this.orderType = (options.type == undefined && options.type != 0) ? '' : parseInt(
  231. options.type);
  232. this.getMarTop();
  233. },
  234. methods: {
  235. delHistory(){
  236. this.tempStorage = []
  237. this.historyList = []
  238. uni.setStorageSync('orderHistoryList', this.tempStorage);
  239. },
  240. getFun() {
  241. this.getOrderData();
  242. this.getOrderList();
  243. },
  244. onLoadFun() {
  245. this.getFun();
  246. this.isShowAuth = false;
  247. },
  248. getMarTop(){
  249. let that = this;
  250. setTimeout(() => {
  251. // 获取小程序头部高度
  252. let info = uni.createSelectorQuery().in(this).select(".header_box");
  253. info.boundingClientRect(function(data) {
  254. that.marTop = data.height
  255. }).exec()
  256. }, 100)
  257. },
  258. /**
  259. * 获取订单统计数据
  260. *
  261. */
  262. getOrderData: function() {
  263. let that = this;
  264. orderData({type: this.orderType,search: this.keyword}).then(res => {
  265. that.$set(that, 'orderData', res.data);
  266. });
  267. },
  268. showModalChange(orderId, type){
  269. this.orderId = orderId;
  270. this.modalType = type;
  271. if(type == 1){
  272. this.modalTitle = '确认收货';
  273. this.modalContent = '为保障权益,请收到货确认无误后,再确认收货';
  274. }else if(type == 2){
  275. this.modalTitle = '删除订单';
  276. this.modalContent = '确定删除该订单?';
  277. }else if(type == 3){
  278. this.modalTitle = '温馨提示';
  279. this.modalContent = '确认取消该订单?';
  280. }
  281. this.showModal = true;
  282. },
  283. handleClick(e){
  284. let index = e.index;
  285. if(index == 1){
  286. if(this.modalType == 1){
  287. orderTake(this.orderId).then(res => {
  288. this.showModal = false;
  289. this.goSearch('');
  290. this.getOrderData();
  291. }).catch(err => {
  292. return this.$util.Tips({
  293. title: err
  294. });
  295. })
  296. }else if(this.modalType == 2){
  297. orderDel(this.orderId).then(res=>{
  298. this.showModal = false;
  299. this.goSearch('');
  300. this.getOrderData();
  301. })
  302. }else if(this.modalType == 3){
  303. this.showModal = false;
  304. orderCancel(this.orderId).then(()=>{
  305. this.goSearch('');
  306. this.getOrderData();
  307. })
  308. }
  309. }else{
  310. this.showModal = false;
  311. }
  312. },
  313. hideModal(){
  314. this.showModal = false;
  315. },
  316. /**
  317. * 取消订单
  318. *
  319. */
  320. cancelOrder: function(index, order_id) {
  321. let that = this;
  322. if (!order_id)
  323. return that.$util.Tips({
  324. title: '缺少订单号无法取消订单'
  325. });
  326. orderCancel(order_id)
  327. .then(res => {
  328. return that.$util.Tips({
  329. title: res.msg,
  330. icon: 'success'
  331. },
  332. function() {
  333. that.orderList.splice(index, 1);
  334. that.$set(that, 'orderList', that.orderList);
  335. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  336. that.getOrderData();
  337. }
  338. );
  339. })
  340. .catch(err => {
  341. return that.$util.Tips({
  342. title: err
  343. });
  344. });
  345. },
  346. goPay: function(order_id) {
  347. uni.reLaunch({
  348. url: `/pages/goods/cashier/index?order_id=${order_id}&from_type=order`
  349. })
  350. },
  351. goOrderDetails: function(order_id) {
  352. if (!order_id)
  353. return that.$util.Tips({
  354. title: '缺少订单号无法查看订单详情'
  355. });
  356. // #ifdef MP
  357. uni.showLoading({
  358. title: '正在加载'
  359. });
  360. openOrderSubscribe()
  361. .then(() => {
  362. uni.hideLoading();
  363. uni.navigateTo({
  364. url: '/pages/goods/order_details/index?order_id=' + order_id
  365. })
  366. })
  367. .catch(err => {
  368. uni.hideLoading();
  369. });
  370. // #endif
  371. // #ifndef MP
  372. uni.navigateTo({
  373. url: '/pages/goods/order_details/index?order_id=' + order_id
  374. });
  375. // #endif
  376. },
  377. /**
  378. * 切换类型
  379. */
  380. statusClick: function(status) {
  381. if (this.loading) return
  382. if (status === this.orderStatus) return;
  383. this.orderStatus = status;
  384. this.loadend = false;
  385. this.page = 1;
  386. this.$set(this, 'orderList', []);
  387. this.getOrderList();
  388. },
  389. searchFocus(){
  390. try {
  391. this.historyList = []
  392. this.tempStorage = []
  393. let arr = uni.getStorageSync('orderHistoryList')
  394. if (arr.length > 0) {
  395. this.historyList = Array.from(new Set(arr))
  396. } else {
  397. this.historyList = []
  398. }
  399. this.tempStorage = this.historyList
  400. } catch (e) {}
  401. this.focus = true;
  402. },
  403. goSearch(keyword){
  404. this.loadend = false;
  405. this.loading = false;
  406. this.keyword = keyword;
  407. this.page = 1;
  408. this.orderList = [];
  409. this.getOrderList();
  410. },
  411. inputConfirm(){
  412. this.loadend = false;
  413. this.loading = false;
  414. this.page = 1;
  415. this.orderList = [];
  416. this.getOrderData();
  417. this.getOrderList();
  418. setTimeout(e => {
  419. let arr = this.tempStorage;
  420. if(this.keyword !== ''){
  421. arr.unshift(this.keyword);
  422. this.tempStorage = [...Array.from(new Set(arr))];
  423. uni.setStorageSync('orderHistoryList', this.tempStorage);
  424. }
  425. }, 1000)
  426. },
  427. /**
  428. * 获取订单列表
  429. */
  430. getOrderList: function() {
  431. let that = this;
  432. if (that.loadend) return;
  433. if (that.loading) return;
  434. that.loading = true;
  435. that.loadTitle = '加载更多';
  436. getOrderList({
  437. status: that.orderStatus,
  438. type: that.orderType,
  439. page: that.page,
  440. limit: that.limit,
  441. search: this.keyword
  442. })
  443. .then(res => {
  444. let list = res.data || [];
  445. let loadend = list.length < that.limit;
  446. that.orderList = that.$util.SplitArray(list, that.orderList);
  447. that.$set(that, 'orderList', that.orderList);
  448. that.loadend = loadend;
  449. that.loading = false;
  450. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  451. that.page = that.page + 1;
  452. that.focus = false;
  453. })
  454. .catch(err => {
  455. that.loading = false;
  456. that.loadTitle = '加载更多';
  457. });
  458. },
  459. /**
  460. * 删除订单
  461. */
  462. delOrder: function(order_id, index) {
  463. let that = this;
  464. uni.showModal({
  465. title: '删除订单',
  466. content: '确定删除该订单',
  467. success: function(res) {
  468. if (res.confirm) {
  469. orderDel(order_id)
  470. .then(res => {
  471. that.orderList.splice(index, 1);
  472. that.$set(that, 'orderList', that.orderList);
  473. that.$set(that.orderData, 'unpaid_count', that.orderData
  474. .unpaid_count - 1);
  475. that.getOrderData();
  476. return that.$util.Tips({
  477. title: '删除成功',
  478. icon: 'success'
  479. });
  480. })
  481. .catch(err => {
  482. return that.$util.Tips({
  483. title: err
  484. });
  485. });
  486. } else if (res.cancel) {
  487. return that.$util.Tips({
  488. title: '已取消'
  489. });
  490. }
  491. }
  492. });
  493. },
  494. goPage(type, url){
  495. if(type == 1){
  496. uni.navigateTo({
  497. url
  498. })
  499. }else if(type == 2){
  500. uni.switchTab({
  501. url
  502. })
  503. }else if(type == 3){
  504. uni.navigateBack();
  505. }
  506. },
  507. },
  508. onReachBottom: function() {
  509. this.getOrderList();
  510. }
  511. };
  512. </script>
  513. <style scoped lang="scss">
  514. .border_con {
  515. border: 1px solid var(--view-theme);
  516. }
  517. .border_ccc {
  518. border: 1rpx solid #ccc;
  519. }
  520. .active {
  521. color: var(--view-theme);
  522. font-weight: 500;
  523. font-size: 30rpx;
  524. }
  525. .abs-rt {
  526. position: absolute;
  527. top: 0;
  528. right: 0;
  529. }
  530. .order_card ~ .order_card{
  531. margin-top:20rpx;
  532. }
  533. .btn ~ .btn{
  534. margin-left: 16rpx;
  535. }
  536. .uni-badge-left-margin {
  537. position: absolute;
  538. top: -16rpx;
  539. right: -30rpx;
  540. /deep/ .uni-badge--error {
  541. background-color: var(--view-theme) !important;
  542. }
  543. .uni-badge {
  544. color: var(--view-theme);
  545. border: 1px solid var(--view-theme);
  546. z-index: 29;
  547. }
  548. }
  549. </style>