order.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <view :style="[mainStyle]">
  3. <!--pages/order/order.wxml-->
  4. <view class="tab">
  5. <view v-for="(item, index) in TabList" :key="index" :class="'li ' + (item.active ? 'active' : '')"
  6. :data-index="index" @tap="switchTab">{{ item.label }}</view>
  7. </view>
  8. <view style="height: 100rpx;"></view>
  9. <view class="search ddflex" v-if="index == 0">
  10. <image src="../../static/pages/images/ssico.png"></image>
  11. <input v-model="search" placeholder="输入关键词搜索" placeholder-class="placeholder" class="ipt fflex"
  12. @confirm="confirmSearch" />
  13. </view>
  14. <block v-if="pageList.length > 0">
  15. <view v-for="(item, index) in pageList" :key="index" class="lists" @tap="showOrder(item)">
  16. <view class="ddbh">
  17. <view class="ddid ddflex fflex ">
  18. {{ item.payTime ? item.payTime : item.createDate }} 下单
  19. <!-- <block v-if="item.state == 1 || item.state == 8">
  20. <image src="/mine/static/mine/images/ioc_hwg.png" class="ioc" v-if="item.orderType==10">
  21. </image>编号:{{item.id}}<text class="copy" @tap="copy(item.id)">复制</text>
  22. </block>
  23. <block v-else>{{item.payTime}} 下单</block> -->
  24. </view>
  25. <!-- //订单状态等于待自提;并且订单类型是需要核销的 -->
  26. <block
  27. v-if="item.state == 7 && (item.orderType == 17 || item.orderType == 18 || item.orderType == 16)">
  28. </block>
  29. <block v-else>
  30. <view class="tihuoma" v-if="item.mode == 1 && item.state < 8 && item.state > 1">
  31. 提货码:
  32. <text>{{ item.code }}</text>
  33. </view>
  34. </block>
  35. <block>
  36. <image src="/static/pages/images/jishida.png" class="type" v-if="item.orderType == 5">
  37. </image>
  38. <image src="/mine/static/mine/images/tuangou.png" class="type" v-if="item.orderType == 2">
  39. </image>
  40. <image src="/mine/static/mine/images/pingtuan.png" class="type" v-if="item.orderType == 4">
  41. </image>
  42. <image src="/mine/static/mine/images/kanjia.png" class="type" v-if="item.orderType == 7">
  43. </image>
  44. <image src="/mine/static/mine/images/seckill.png" class="type" v-if="item.orderType == 3">
  45. </image>
  46. <image src="/mine/static/mine/images/newbornZone.png" class="type"
  47. v-if="item.orderType == 6">
  48. </image>
  49. </block>
  50. </view>
  51. <view :data-code="item.code" :data-id="item.id" :data-state="item.state">
  52. <view v-for="(itempro, index2) in item.products" :key="index2" class="li">
  53. <image :src="itempro.pic + '?x-oss-process=style/w160'" mode="aspectFill" class="cimg">
  54. </image>
  55. <view class="zhinfo">
  56. <view class="zhtit ddflex">
  57. <view class="fflex tover">{{ itempro.title }}</view>
  58. <view class="zhjia" v-if="item.orderType != 11">¥{{ itempro.salePrice }}</view>
  59. <view class="zhjia" v-if="item.orderType == 11">
  60. {{ itempro.integral }}积分+¥{{ itempro.salePrice }}
  61. </view>
  62. </view>
  63. <view class="gg ddflex">
  64. <view v-if="itempro.propertiesList" class="guigecontent fflex">
  65. <block v-if="itempro.propertiesList && itempro.propertiesList.length > 0">
  66. 规格:
  67. <text v-for="(itemGuige, index) in itempro.propertiesList" :key="index"
  68. class="guige" decode="true">{{ itemGuige.value }}&nbsp;</text>
  69. </block>
  70. </view>
  71. <view class="num">×{{ itempro.quantity }}</view>
  72. </view>
  73. <view class="yuji" v-if="itempro.estimatedDeliveryTime">
  74. {{ itempro.estimatedDeliveryTimeStr }}前发货
  75. </view>
  76. </view>
  77. </view>
  78. <view class="total dflex">
  79. <!-- <view>共{{item.count}}件商品</view> -->
  80. <view v-if="item.orderType != 11">
  81. 总金额:
  82. <text>¥{{ item.money }}</text>
  83. </view>
  84. <view v-if="item.orderType == 11">
  85. 合计:
  86. <text>{{ item.discountMoney }}积分+¥{{ item.money }}</text>
  87. </view>
  88. <view v-if="item.discountMoney > 0 && item.orderType != 11">
  89. 优惠金额:
  90. <text>¥{{ item.discountMoney }}</text>
  91. </view>
  92. </view>
  93. </view>
  94. <view class="status">
  95. <block v-if="item.mode == 1 && item.state == 3">
  96. <view class="flex">待配货</view>
  97. </block>
  98. <block v-else>
  99. <block v-if="item.state == 7 && item.orderType == 17">
  100. <view class="flex">订单完成</view>
  101. </block>
  102. <view v-else class="flex">{{ item.stateName }}</view>
  103. </block>
  104. <!-- <block v-if="item.orderType==4">
  105. </block>
  106. <block v-else>
  107. <view class="sta-btn" @tap="refund" :data-id="item.id" :data-index="index"
  108. v-if="item.refund>0&&item.state>=2&&item.state<=6 && isrefund==1&&(item.orderType!=4)&&item.payTime!=null ||(item.state >=20&&item.state <30&&item.isOtc=='1'&& isrefund==1&&item.payTime!=null)">
  109. 申请售后</view>
  110. </block> -->
  111. <view class="sta-btn" @click.stop="cancelOrder" :data-index="index" v-if="item.state == 1">取消订单
  112. </view>
  113. <view class="sta-btn" @click.stop="jumpUrl('/service/secondCard/secondCard')"
  114. :data-index="index" v-if="item.state == 7 && item.orderType == 18">去使用</view>
  115. <!-- <view class="sta-btn" @tap="cancelOrder" :data-index="index" v-if="item.state == 3">提醒发货</view> -->
  116. <view class="sta-btn" @click.stop="txOrder" :data-index="index"
  117. v-if="item.state == 3 && item.isReminder == 1">提醒发货</view>
  118. <!-- <block
  119. v-if="isOpenInvoice == 1 && (item.state == 2 || item.state == 3 || item.state == 4 || item.state == 5 || item.state == 6 || item.state == 7)">
  120. <view class="sta-btn" @click.stop="applyInvoice(item)" v-if="item.invoiceState == 0">申请开票
  121. </view>
  122. <view class="sta-btn" @click.stop="toInvoice()" v-else>查看发票</view>
  123. </block> -->
  124. <!-- <navigator class="sta-btn" url="/mine/orderDet/orderDet?id={{item.id}}" hover-class="none">查看详情</navigator> -->
  125. <view class="sta-btn red" @click.stop="confirmOrder" :data-index="index"
  126. v-if="item.state == 5 || item.state == 6">确认收货</view>
  127. <view @click.stop="payOrder(item, index)" class="sta-btn red" v-if="item.state == 1">立即付款</view>
  128. <view @click.stop="scoreOrder" :data-index="index" class="sta-btn red"
  129. v-if="item.state == 7 && isOpenComments == 1 && item.isEvaluate == 0">立即评价</view>
  130. <navigator v-if="item.state == 22 || item.state == 20 || item.state == 27" hover-class="none"
  131. :url="'/prescription/Consultation/index?orderId=' + item.id" class="sta-btn red">
  132. 重新开方
  133. </navigator>
  134. </view>
  135. </view>
  136. </block>
  137. <view class="nodata" v-if="ishow">
  138. <image :src="picUrlss + 'empty_dd.png'"></image>
  139. <text>还没有订单哦</text>
  140. </view>
  141. </view>
  142. </template>
  143. <script>
  144. // pages/order/order.js
  145. const app = getApp();
  146. const req = require('../../utils/request.js');
  147. const requsetmessage = require('../../utils/requestmessage.js');
  148. export default {
  149. data() {
  150. return {
  151. mainStyle: app.globalData.mainStyle,
  152. picUrlss: req.public.picUrls,
  153. systems: {},
  154. TabList: [{
  155. label: '全部',
  156. active: true
  157. }, {
  158. label: '待付款',
  159. state: 1
  160. }, {
  161. label: '待发货',
  162. state: 3
  163. }, {
  164. label: '待收货',
  165. state: 5
  166. }, {
  167. label: '已完成',
  168. state: 7
  169. }],
  170. form: {
  171. page: 1,
  172. limit: 10
  173. },
  174. pageList: [],
  175. isLoad: true,
  176. index: '',
  177. ishow: false,
  178. isrefund: '',
  179. isOpenComments: '',
  180. isOpenInvoice: '',
  181. search: '',
  182. payItem: '',
  183. isPay: false,
  184. };
  185. },
  186. components: {},
  187. props: {},
  188. beforeMount() {
  189. const systemInfo = uni.getSystemInfoSync();
  190. console.log('systemInfo==', systemInfo)
  191. // px转换到rpx的比例
  192. let pxToRpxScale = 750 / systemInfo.windowWidth;
  193. let systems = {
  194. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  195. navigationHeight: 44 * pxToRpxScale, // 导航栏的高度
  196. windowHeight: systemInfo.screenHeight * pxToRpxScale, // 导航栏的高度
  197. safeBottomHeight: systemInfo.safeAreaInsets.bottom * pxToRpxScale
  198. };
  199. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  200. systems.windowHeights = systems.windowHeight - 115 - systems.safeBottomHeight;
  201. // this.sheight = (500/pxToRpxScale)/2;
  202. this.systems = systems;
  203. console.log('systems==', systems)
  204. },
  205. onLoad: function(options) {
  206. let that = this;
  207. let title = '';
  208. this.isrefundFun();
  209. this.isOpenCommentsFun();
  210. if (options.orderType) {
  211. this.form.orderType = options.orderType;
  212. if (options.orderType == 2) title = '团购订单';
  213. if (options.orderType == 4) title = '拼团订单';
  214. if (options.orderType == 7) title = '砍价订单';
  215. uni.setNavigationBarTitle({
  216. title: title
  217. });
  218. }
  219. const index = that.TabList.findIndex(it => it.state == options.state);
  220. if (options && options.state > 0)
  221. that.switchTab({
  222. currentTarget: {
  223. dataset: {
  224. index: index
  225. }
  226. }
  227. });
  228. else that.getList();
  229. this.setData({
  230. index: index
  231. });
  232. },
  233. onShow() {
  234. this.switchTab({
  235. currentTarget: {
  236. dataset: {
  237. index: this.index
  238. }
  239. }
  240. });
  241. // #ifdef H5
  242. if (this.payItem && this.isPay) {
  243. this.isPay = false;
  244. req.checkPaySuccess(this.payItem.id, sucs => {
  245. console.log('付款结果>>>>', sucs);
  246. this.payJumpSuc(this.payItem, sucs);
  247. this.payItem = '';
  248. });
  249. }
  250. // #endif
  251. },
  252. onReachBottom() {
  253. this.form.page++;
  254. this.getList();
  255. },
  256. methods: {
  257. switchTab(event) {
  258. let index = event.currentTarget.dataset.index;
  259. // console.log(index);
  260. let def = this.TabList.findIndex(it => it.active);
  261. let d = {};
  262. d['TabList[' + def + '].active'] = false;
  263. d['TabList[' + index + '].active'] = true;
  264. this.isLoad = true;
  265. this.form.page = 1;
  266. this.search = '';
  267. d['pageList'] = []; // this.data.form.states=this.data.TabList[index].state.toString();
  268. this.form.state = this.TabList[index].state;
  269. this.setData({
  270. index: index
  271. });
  272. this.setData(d);
  273. this.getList();
  274. },
  275. confirmSearch() {
  276. this.isLoad = true;
  277. this.form.page = 1;
  278. this.getList();
  279. },
  280. getList() {
  281. let isShowLoading = false;
  282. if (this.form.page == 1 && !isShowLoading) {
  283. req.loadIng('加载中');
  284. isShowLoading = true;
  285. }
  286. // console.log(!this.isLoad);
  287. if (!this.isLoad) return false;
  288. this.isLoad = false;
  289. let that = this;
  290. let form = this.form;
  291. if (this.search) {
  292. form.search = this.search;
  293. } else {
  294. delete form.search;
  295. }
  296. req.getRequest('/api/order/list', form, data => {
  297. // console.log(data);
  298. if (data && data.length == 10) this.isLoad = true;
  299. if (that.form.page > 1) data = that.pageList.concat(data);
  300. data.map(el => {
  301. el.refund = el.products.filter(it => it.quantity - (it.refundStock ? it
  302. .refundStock : 0) > 0).length;
  303. return el;
  304. });
  305. // console.log(data)
  306. that.setData({
  307. pageList: data
  308. });
  309. // console.log(data);
  310. if (data.length <= 0) {
  311. that.setData({
  312. ishow: true
  313. });
  314. } else {
  315. that.setData({
  316. ishow: false
  317. });
  318. }
  319. if (isShowLoading) {
  320. uni.hideLoading();
  321. isShowLoading = false;
  322. }
  323. });
  324. },
  325. showOrder(item) {
  326. let id = item.id;
  327. let code = item.code;
  328. let state = item.state;
  329. if (item.state == 7 && item.orderType == 17) { //17 虚拟产品订单 18 线下服务
  330. //进入核销订单详情页面
  331. app.globalData.openPage('service/virtuallyDetail/index?id=' + item.id);
  332. } else {
  333. //进入常规订单详情
  334. app.globalData.openPage('mine/orderDet/orderDet?id=' + id + '&isrefund=' + this.isrefund + '&code=' +
  335. code);
  336. }
  337. },
  338. txOrder(event) {
  339. let index = event.currentTarget.dataset.index;
  340. let page = this.pageList[index];
  341. let that = this;
  342. req.postRequest(
  343. '/api/order/reminderOrder', {
  344. orderId: page.id
  345. },
  346. () => {
  347. req.msg('发货提醒成功');
  348. }
  349. );
  350. },
  351. cancelOrder(event) {
  352. //取消订单
  353. let index = event.currentTarget.dataset.index;
  354. let page = this.pageList[index];
  355. let that = this;
  356. req.msgConfirm('确定取消该订单?', () => {
  357. req.postRequest(
  358. '/api/order/cancel', {
  359. id: page.id
  360. },
  361. () => {
  362. let d = {};
  363. d['pageList[' + index + '].stateName'] = '订单取消';
  364. d['pageList[' + index + '].state'] = 8;
  365. that.setData(d);
  366. that.switchTab({
  367. currentTarget: {
  368. dataset: {
  369. index: this.index
  370. }
  371. }
  372. });
  373. }
  374. );
  375. });
  376. },
  377. confirmOrder(event) {
  378. //确认收货
  379. let index = event.currentTarget.dataset.index;
  380. let page = this.pageList[index];
  381. let that = this;
  382. // console.log(that.index);
  383. req.msgConfirm('确认执行该操作?', () => {
  384. req.postRequest(
  385. '/api/order/receiving', {
  386. id: page.id
  387. },
  388. () => {
  389. let d = {};
  390. d['pageList[' + index + '].stateName'] = '订单完成';
  391. d['pageList[' + index + '].state'] = 7;
  392. that.setData(d);
  393. that.switchTab({
  394. currentTarget: {
  395. dataset: {
  396. index: this.index
  397. }
  398. }
  399. });
  400. }
  401. );
  402. });
  403. },
  404. payOrder: async function(item) {
  405. let _ts = this;
  406. _ts.isPay = true;
  407. let mode = item.mode;
  408. if (item.mode == 2 && item.orderType == 5) {
  409. mode = 3;
  410. }
  411. _ts.payItem = item;
  412. // #ifdef MP-WEIXIN
  413. if (item.isOtc == 1) {
  414. await requsetmessage.recipel(mode).then(res => {});
  415. } else if (mode == 1) {
  416. await requsetmessage.selfRaising().then(res => {
  417. // console.log("自提", res);
  418. });
  419. } else if (mode == 2) {
  420. await requsetmessage.distribution().then(res => {
  421. // console.log("配送", res);
  422. });
  423. } else {
  424. await requsetmessage.jisda().then(res => {
  425. // console.log("及时达", res);
  426. });
  427. }
  428. // #endif
  429. //支付订单
  430. req.payOrder(item.id, success => {
  431. // console.log(success);
  432. _ts.payJumpSuc(item, success);
  433. });
  434. },
  435. payJumpSuc(sucs) {
  436. this.orderId = '';
  437. if (sucs) {
  438. if (item.isOtc == 1) {
  439. app.globalData.redirectTab('product/pay/pay?isSuccess=true&orderId=' + item.id +
  440. '&isRx=1');
  441. } else {
  442. app.globalData.redirectTab('product/pay/pay?isSuccess=true');
  443. }
  444. }
  445. },
  446. refund(event) {
  447. //申请退款
  448. let id = event.currentTarget.dataset.id;
  449. uni.navigateTo({
  450. url: '/mine/refund/refundType/refundType?id=' + id
  451. }); // let id = event.currentTarget.dataset.id;
  452. // req.postRequest('/api/order/refund',{id:id},res=>{
  453. // req.msg('退款审核中')
  454. // })
  455. },
  456. isrefundFun() {
  457. //是否开启售后
  458. let isrefund = JSON.parse(req.getStorage('configRes'));
  459. if (isrefund.isRefund) {
  460. this.setData({
  461. isrefund: isrefund.isRefund
  462. });
  463. } // if(isrefund.isRefund==1){
  464. // req.getRequest('/api/orderRefund/refundReason','',data=>{
  465. // req.setStorage('isrefund',data)
  466. // })
  467. // }
  468. },
  469. isOpenCommentsFun() {
  470. //是否开启评论
  471. let isOpenComments = JSON.parse(req.getStorage('configRes'));
  472. if (isOpenComments.is_open_comments) {
  473. this.setData({
  474. isOpenComments: isOpenComments.is_open_comments
  475. });
  476. }
  477. if (isOpenComments.is_open_invoice) {
  478. this.setData({
  479. isOpenInvoice: isOpenComments.is_open_invoice
  480. });
  481. }
  482. },
  483. scoreOrder(event) {
  484. //评价订单
  485. let index = event.currentTarget.dataset.index;
  486. let page = this.pageList[index];
  487. let that = this;
  488. app.globalData.openPage('mine/comments/comments?id=' + page.id);
  489. },
  490. copy(id) {
  491. uni.setClipboardData({
  492. data: id,
  493. complete() {
  494. req.msg('复制成功');
  495. }
  496. });
  497. },
  498. // 申请开票
  499. applyInvoice(item) {
  500. uni.navigateTo({
  501. url: '/invoice/apply/apply?orderId=' + item.id + '&money=' + item.money
  502. });
  503. },
  504. toInvoice() {
  505. uni.navigateTo({
  506. url: '/mine/invoice/invoice'
  507. });
  508. },
  509. jumpUrl(url) {
  510. uni.navigateTo({
  511. url: url
  512. })
  513. }
  514. //订单类型
  515. //普通订单 1, 社区团购订单 2,秒杀订单 3, 拼团订单 4,及时达订单 5,新客特价 6,优惠砍价 7, 海外购订单 10,积分订单 11,组合订单 12,代客下单 13,收银台下单 14,处方订单 15,门店消费订单 16,虚拟订单 17,服务订单 18,混合订单 20,自助开团-齐育未来 21,分次付款订单-齐育未来 22,团购订单-蜜团团 23,优惠券-虚拟品订单 24,挂号 47,课程组 48,课程 49,众筹订单 86,捐款记录 87,回收订单 88,门店收款订单 89,分批付款订单 90,试卷订单 91,充值订单 92,收款订单 93,预约订单 94,VIP购买订单 96,平台功能订单 97,加入协会 98,赛事订单 99
  516. }
  517. };
  518. </script>
  519. <style>
  520. @import './order.css';
  521. </style>