myOrder.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <view class="container">
  3. <tui-tabs v-if="module==version3" :top="0" :tabs="ptypeTabs" :isFixed="scrollTop>=0" :height="88"
  4. :currentTab="currentPtype" :sliderWidth="300" :sliderHeight="60" itemWidth="50%" bottom="50%" color="#888"
  5. selectedColor="#5677fc" :bold="true" sliderBgColor="#E5FAFF" @change="ptypechange">
  6. </tui-tabs>
  7. <tui-tabs :top="module==version3 ? 40 : 0" :tabs="statusType" :isFixed="scrollTop>=0" :currentTab="currentTab"
  8. selectedColor="#E41F19" sliderBgColor="#E41F19" @change="statusTap" itemWidth="20%"></tui-tabs>
  9. <!--选项卡逻辑自己实现即可,此处未做处理-->
  10. <view :style="'margin-top:'+ (module==version3 ? 160 : 80)+'rpx'" :class="{'tui-order-list':scrollTop>=0}">
  11. <view class="tui-order-item" v-for="(item,orderIndex) in orderList" :key="orderIndex">
  12. <tui-list-cell @click="orderDetail(item.id)" :hover="false" :lineLeft="false">
  13. <view class="tui-goods-title">
  14. <view>订单号:{{item.order_num_alias}}</view>
  15. <view class="tui-order-status">{{item.statusStr}}</view>
  16. </view>
  17. </tui-list-cell>
  18. <block v-if="item.cat_id">
  19. <tui-list-cell padding="0" @click="orderDetail(item.id)">
  20. <view class="tui-goods-item">
  21. <image :src="item.cateMap.image || '/static/images/default_img.png'" class="tui-goods-img"
  22. mode="widthFix"></image>
  23. <view class="tui-goods-center">
  24. <view class="tui-goods-name">{{item.pay_subject}}</view>
  25. <view v-if="item.remark" class="tui-goods-attr">{{item.remark}}</view>
  26. </view>
  27. <view class="tui-price-right">
  28. <view>x1</view>
  29. </view>
  30. </view>
  31. </tui-list-cell>
  32. </block>
  33. <block v-else-if="item.is_errands==1">
  34. <tui-list-cell padding="0" @click="orderDetail(item.id)">
  35. <view class="tui-goods-item">
  36. <image :src="item.image || '/static/images/default_img.png'" class="tui-goods-img"
  37. mode="widthFix"></image>
  38. <view class="tui-goods-center">
  39. <view class="tui-goods-name">{{item.pay_subject}}</view>
  40. <view v-if="item.remark" class="tui-goods-attr">{{item.remark}}</view>
  41. </view>
  42. <view class="tui-price-right">
  43. <view>x1</view>
  44. </view>
  45. </view>
  46. </tui-list-cell>
  47. </block>
  48. <block v-else>
  49. <block v-for="(goodsitem,index) in item.goodsMap" :key="index">
  50. <tui-list-cell padding="0" @click="orderDetail(item.id)">
  51. <view class="tui-goods-item">
  52. <image :src="goodsitem.image" class="tui-goods-img" mode="widthFix"></image>
  53. <view class="tui-goods-center">
  54. <view class="tui-goods-name">{{goodsitem.name}}</view>
  55. <view v-if="goodsitem.label" class="tui-goods-attr">{{goodsitem.label}}</view>
  56. </view>
  57. <view class="tui-price-right">
  58. <view>¥{{goodsitem.price}}</view>
  59. <view>x{{goodsitem.quantity}}</view>
  60. </view>
  61. </view>
  62. </tui-list-cell>
  63. </block>
  64. </block>
  65. <tui-list-cell :hover="false" unlined>
  66. <view class="tui-goods-price">
  67. <view>
  68. <!--共4件商品--> 合计:
  69. </view>
  70. <view class="tui-size-24">¥</view>
  71. <view class="tui-price-large">{{item.total}}</view>
  72. <view class="tui-size-24"></view>
  73. </view>
  74. </tui-list-cell>
  75. <view class="tui-order-btn">
  76. <!--<view class="tui-btn-ml">
  77. <tui-button type="black" plain width="152rpx" height="56rpx" :size="26" shape="circle"
  78. @click="invoiceDetail">查看发票</tui-button>
  79. </view>-->
  80. <view v-if="item.order_status_id==1" class="tui-btn-ml">
  81. <tui-button @click="cancelOrderTap(item.id)" type="black" plain width="152rpx" height="56rpx"
  82. :size="26" shape="circle">取消订单</tui-button>
  83. </view>
  84. <view v-if="item.order_status_id==3 && item.ptype==1" class="tui-btn-ml">
  85. <tui-button @click="confirmBtnTap(item.id)" type="black" plain width="152rpx" height="56rpx"
  86. :size="26" shape="circle">确认收货</tui-button>
  87. </view>
  88. <view v-if="item.order_status_id==5 && item.ptype==2" class="tui-btn-ml">
  89. <tui-button @click="confirmBtnTap(item.id)" type="black" plain width="152rpx" height="56rpx"
  90. :size="26" shape="circle">确认验收</tui-button>
  91. </view>
  92. <view class="tui-btn-ml">
  93. <tui-button @click="orderDetail(item.id)" type="black" plain width="152rpx" height="56rpx"
  94. :size="26" shape="circle">订单详情</tui-button>
  95. </view>
  96. <view v-if="item.paymethod.code=='offline_pay' && item.is_offline_pay<1 && item.order_status_id==1"
  97. class="tui-btn-ml">
  98. <tui-button type="black" plain width="152rpx" height="56rpx" :size="26" shape="circle"
  99. @click="offlinepaymentTap(item.id)">支付凭证</tui-button>
  100. </view>
  101. <view v-if="item.paymethod.code=='wx_pay' && item.order_status_id==1" class="tui-btn-ml">
  102. <tui-button type="danger" plain width="152rpx" height="56rpx" :size="26" shape="circle"
  103. @click="toPayTap(item.total,item.id)">立即支付</tui-button>
  104. </view>
  105. <view v-if="item.order_status_id==5 && item.is_comment==0" class="tui-btn-ml">
  106. <tui-button type="black" plain width="152rpx" height="56rpx" :size="26" shape="circle"
  107. @click="addEvaluate(item.id)">评价</tui-button>
  108. </view>
  109. <!--<view class="tui-btn-ml">
  110. <tui-button type="danger" plain width="152rpx" height="56rpx" :size="26" shape="circle">再次购买
  111. </tui-button>
  112. </view>-->
  113. </view>
  114. </view>
  115. </view>
  116. <!--加载loadding-->
  117. <tui-loadmore v-if="loadding" :index="3" type="red"></tui-loadmore>
  118. <tui-nomore v-if="!pullUpOn" backgroundColor="#fafafa"></tui-nomore>
  119. <!--加载loadding-->
  120. <tui-tabbar v-if="from=='bottom'" :current="current">
  121. </tui-tabbar>
  122. </view>
  123. </template>
  124. <script>
  125. import pay from '@/common/pay.js'
  126. export default {
  127. data() {
  128. return {
  129. ptypeTabs: [{
  130. name: "服务订单"
  131. }, {
  132. name: "商品订单"
  133. }],
  134. current: '',
  135. from: '',
  136. tabBar: [],
  137. module: this.$module,
  138. version2: this.$version2,
  139. version3: this.$version3,
  140. statusType: [],
  141. ptype: 2,
  142. ispoints: '',
  143. currentPtype: 0,
  144. orderStatus: 0,
  145. currentTab: 0,
  146. pageIndex: 1,
  147. loadding: false,
  148. pullUpOn: true,
  149. scrollTop: 0,
  150. orderList: [],
  151. where: {
  152. status: 0,
  153. ptype: 0,
  154. keyword: '',
  155. page: 1,
  156. limit: 10,
  157. },
  158. }
  159. },
  160. onLoad: function(e) {
  161. let _this = this
  162. // #ifdef MP-WEIXIN
  163. this.current = "/" + this.__route__;
  164. // #endif
  165. //#ifdef H5
  166. this.current = this.$route.path;
  167. //#endif
  168. _this.from = e.from;
  169. if (e.currentTab) {
  170. _this.currentTab = e.currentTab;
  171. }
  172. if (e.ispoints) {
  173. _this.ispoints = e.ispoints;
  174. }
  175. if (e.ptype) {
  176. _this.ptype = e.ptype;
  177. }
  178. if (_this.ptype == 2) {
  179. _this.currentPtype = 0;
  180. } else {
  181. _this.currentPtype = 1;
  182. }
  183. //console.log(e);
  184. _this.getorderstatus();
  185. },
  186. onShow: function(e) {
  187. let _this = this
  188. _this.$util.getUserInfo(function(userInfo) {
  189. console.log(userInfo);
  190. _this.getorderlist(true);
  191. });
  192. },
  193. methods: {
  194. statusTap: function(e) {
  195. this.currentTab = e.index
  196. this.orderStatus = this.statusType[this.currentTab].id;
  197. this.getorderlist(true);
  198. },
  199. ptypechange: function(e) {
  200. this.currentPtype = e.index
  201. if (this.currentPtype == 0) {
  202. this.ptype = 2;
  203. } else {
  204. this.ptype = 1;
  205. }
  206. this.getorderstatus();
  207. this.getorderlist(true);
  208. },
  209. getorderstatus: function() {
  210. let _this = this
  211. _this.$request.get('orderstatus.listname', {
  212. ptype: _this.ptype,
  213. samkey: (new Date()).valueOf(),
  214. }).then(res => {
  215. if (res.errno == 0) {
  216. _this.statusType = res.data;
  217. _this.orderStatus = _this.statusType[_this.currentTab].id;
  218. }
  219. })
  220. },
  221. getorderlist: function(isPage) {
  222. var _this = this
  223. console.log(_this.loadend);
  224. if (_this.loading) return;
  225. if (isPage === true) {
  226. _this.where.page = 1;
  227. _this.orderList = [];
  228. } else {
  229. if (_this.loadend) return;
  230. }
  231. _this.where.samkey = (new Date()).valueOf();
  232. _this.where.ptype = _this.ptype;
  233. _this.where.status = _this.orderStatus;
  234. _this.where.currentTab = _this.currentTab;
  235. _this.where.ispoints = _this.ispoints;
  236. console.log(_this.where);
  237. _this.$request.post('order.myorder', _this.where).then(res => {
  238. if (res.errno == 0) {
  239. _this.orderList = _this.orderList.concat(res.data.data);
  240. _this.where.page = _this.where.page + 1
  241. _this.loadend = _this.orderList.length < _this.where.limit;
  242. }
  243. _this.loading = false;
  244. })
  245. },
  246. toPayTap: function(total, orderid) {
  247. const redirectUrl = "/pagesA/my/myOrder/myOrder?ptype=" + this.ptype + "&ispoints=" + this.ispoints;
  248. pay.wxpay('order', total, orderid, redirectUrl);
  249. },
  250. cancelOrderTap: function(orderid) {
  251. var _this = this;
  252. uni.showModal({
  253. title: '确定要取消该订单吗?',
  254. content: '',
  255. success: function(res) {
  256. if (res.confirm) {
  257. _this.$request.post('order.cancel', {
  258. orderid: orderid
  259. }).then(res => {
  260. if (res.errno == 0) {
  261. _this.getorderlist(true);
  262. }
  263. })
  264. }
  265. }
  266. })
  267. },
  268. confirmBtnTap: function(orderid) {
  269. let _this = this;
  270. uni.showModal({
  271. title: _this.module == _this.version3 ? '确认验收?' : '确认您已收到商品?',
  272. content: '',
  273. success: function(res) {
  274. if (res.confirm) {
  275. _this.$request.post('order.delivery', {
  276. orderid: orderid
  277. }).then(res => {
  278. if (res.errno == 0) {
  279. _this.getorderlist(true);
  280. }
  281. });
  282. }
  283. }
  284. });
  285. },
  286. orderDetail: function(orderid) {
  287. var url = '/pagesA/my/myOrder/orderDetail?id=' + orderid;
  288. if (this.ptype == 2) {
  289. url = '/pagesA/my/myOrder/yuyueDetail?id=' + orderid;
  290. }
  291. uni.navigateTo({
  292. url: url
  293. })
  294. },
  295. //线下付款处理
  296. offlinepaymentTap: function(orderid) {
  297. uni.navigateTo({
  298. url: '/pagesA/submitOrder/offlinepayment?id=' + orderid
  299. })
  300. },
  301. invoiceDetail() {
  302. this.tui.href('/pagesA/my/invoiceDetail/invoiceDetail')
  303. },
  304. addEvaluate(orderid) {
  305. this.tui.href('/pagesA/my/addEvaluate/addEvaluate?id=' + orderid)
  306. }
  307. },
  308. /**
  309. * 页面相关事件处理函数--监听用户下拉动作
  310. */
  311. onPullDownRefresh: function() {
  312. this.where.page = 1;
  313. this.loadend = false;
  314. this.orderList = [];
  315. this.getorderlist();
  316. setTimeout(() => {
  317. uni.stopPullDownRefresh()
  318. }, 200);
  319. },
  320. /**
  321. * 页面上拉触底事件的处理函数
  322. */
  323. onReachBottom() {
  324. //只是测试效果,逻辑以实际数据为准
  325. this.loadding = true
  326. this.pullUpOn = true
  327. this.getorderlist();
  328. setTimeout(() => {
  329. this.loadding = false
  330. this.pullUpOn = false
  331. }, 1000)
  332. },
  333. onPageScroll(e) {
  334. this.scrollTop = e.scrollTop;
  335. }
  336. }
  337. </script>
  338. <style>
  339. .container {
  340. padding-bottom: env(safe-area-inset-bottom);
  341. }
  342. .tui-order-list {}
  343. .tui-order-item {
  344. margin-top: 20rpx;
  345. border-radius: 10rpx;
  346. overflow: hidden;
  347. }
  348. .tui-goods-title {
  349. width: 100%;
  350. font-size: 28rpx;
  351. display: flex;
  352. align-items: center;
  353. justify-content: space-between;
  354. }
  355. .tui-order-status {
  356. color: #888;
  357. font-size: 26rpx;
  358. }
  359. .tui-goods-item {
  360. width: 100%;
  361. padding: 20rpx 30rpx;
  362. box-sizing: border-box;
  363. display: flex;
  364. justify-content: space-between;
  365. }
  366. .tui-goods-img {
  367. width: 180rpx;
  368. height: 180rpx;
  369. display: block;
  370. flex-shrink: 0;
  371. }
  372. .tui-goods-center {
  373. flex: 1;
  374. padding: 20rpx 8rpx;
  375. box-sizing: border-box;
  376. }
  377. .tui-goods-name {
  378. max-width: 310rpx;
  379. word-break: break-all;
  380. overflow: hidden;
  381. text-overflow: ellipsis;
  382. display: -webkit-box;
  383. -webkit-box-orient: vertical;
  384. -webkit-line-clamp: 2;
  385. font-size: 26rpx;
  386. line-height: 32rpx;
  387. }
  388. .tui-goods-attr {
  389. font-size: 22rpx;
  390. color: #888888;
  391. line-height: 32rpx;
  392. padding-top: 20rpx;
  393. word-break: break-all;
  394. overflow: hidden;
  395. text-overflow: ellipsis;
  396. display: -webkit-box;
  397. -webkit-box-orient: vertical;
  398. -webkit-line-clamp: 2;
  399. }
  400. .tui-price-right {
  401. text-align: right;
  402. font-size: 24rpx;
  403. color: #888888;
  404. line-height: 30rpx;
  405. padding-top: 20rpx;
  406. }
  407. .tui-color-red {
  408. color: #E41F19;
  409. padding-right: 30rpx;
  410. }
  411. .tui-goods-price {
  412. width: 100%;
  413. display: flex;
  414. align-items: flex-end;
  415. justify-content: flex-end;
  416. font-size: 24rpx;
  417. }
  418. .tui-size-24 {
  419. font-size: 24rpx;
  420. line-height: 24rpx;
  421. }
  422. .tui-price-large {
  423. font-size: 32rpx;
  424. line-height: 30rpx;
  425. font-weight: 500;
  426. }
  427. .tui-order-btn {
  428. width: 100%;
  429. display: flex;
  430. align-items: center;
  431. justify-content: flex-end;
  432. background: #fff;
  433. padding: 10rpx 30rpx 20rpx;
  434. box-sizing: border-box;
  435. }
  436. .tui-btn-ml {
  437. margin-left: 20rpx;
  438. }
  439. </style>