orderItem.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <template>
  2. <view class="container">
  3. <view class="order-row" @click="goToOrderDetail()">
  4. <view class="shop-info" v-if="orderData" @click.stop="gotoShop()">
  5. <text class="iconfont icondianpu"></text>
  6. <text class="shop-name">{{orderData.supplierName}}</text>
  7. <text class="iconfont iconfangxiang" v-if="orderData.tenantCode != 'admin'"></text>
  8. <text class="order-type">{{orderData.auctionStatus == null ? getOrderType(orderData.orderStatus) : getAuctionType(orderData.auctionStatus,orderData.orderStatus)}}</text>
  9. </view>
  10. <view class="goods-list" v-if="orderData">
  11. <view class="goods-row" v-for="(site, index) in orderData.products" :key="index">
  12. <image class="goods-img" :src="site.imgUrl" mode="aspectFill"></image>
  13. <view class="goods-info">
  14. <view class="goods-name">{{site.productName}}</view>
  15. <view class="goods-type">
  16. 类型:{{site.productType == 1 ? '普通商品' : (site.productType == 2 ? '拍卖' : (site.productType == 3 ? '自助采摘' : '共享种植'))}}
  17. </view>
  18. <view class="goods-price-number">
  19. <text class="goods-unit">¥</text>
  20. <text class="goods-price">{{site.bizPrice}}</text>
  21. <text class="goods-number">x{{site.buyNum}}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="pay-info">总价¥{{getAllPrice()}},实付¥{{orderData.paySum}}</view>
  27. <view class="handle-box" v-if="tabIndex > 1">
  28. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  29. v-if="tabIndex == 2" @click.stop="handleOrder(1)">取消订单</u-button>
  30. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  31. v-if="tabIndex == 2" @click.stop="handleOrder(2)">立即支付</u-button>
  32. <!-- <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  33. v-if="tabIndex != 1 && tabIndex != 2" @click.stop="handleOrder(3)">申请售后</u-button> -->
  34. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  35. v-if="(tabIndex == 2 || tabIndex == 3) && pickHandle" @click.stop="handleOrder(4)">自助采摘</u-button>
  36. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  37. v-if="tabIndex == 3 && sharePlant" @click.stop="handleOrder(8)">我的种植</u-button>
  38. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  39. v-if="tabIndex == 4 && sharePlant" @click.stop="handleOrder(8)">我的种植</u-button>
  40. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  41. v-if="tabIndex == 4" @click.stop="handleOrder(5)">确认收货</u-button>
  42. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  43. v-if="tabIndex == 4" @click.stop="handleOrder(6)">追踪物流</u-button>
  44. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  45. v-if="tabIndex == 5 && sharePlant" @click.stop="handleOrder(8)">我的种植</u-button>
  46. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  47. v-if="tabIndex == 5 && orderData.evaluateStatus == 1" @click.stop="handleOrder(7)">评价</u-button>
  48. </view>
  49. <u-modal v-model="modalShow" :content="modalContent" @confirm="submitHandle" :async-close="true" :show-cancel-button="true"></u-modal>
  50. <u-top-tips ref="uTips"></u-top-tips>
  51. </view>
  52. <view class="uni-popup-dialog" :hidden="show_qx">
  53. <view class="uni-dialog-title">
  54. <text class="uni-dialog-title-text">提示</text>
  55. </view>
  56. <view class="uni-dialog-content">
  57. <text class="uni-dialog-content-text">请在设置中开启摄像头权限和麦克风权限</text>
  58. </view>
  59. <view class="uni-dialog-button-group">
  60. <button class="uni-dialog-button uni-border-left" open-type="openSetting" @click="closeSetting">
  61. 设置权限
  62. </button>
  63. </view>
  64. </view>
  65. <view class="qx_bg" :hidden="show_qx">
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. const NET = require('@/utils/request')
  71. const API = require('@/config/api')
  72. export default {
  73. props: {
  74. tabIndex: {
  75. default: 1
  76. },
  77. orderData: {
  78. default: {
  79. auctionStatus: 0,
  80. orderId: 0,
  81. orderStatus: 0,
  82. evaluateReplyStatus: 0,
  83. nickname: '',
  84. payStatus: 0,
  85. paySum: 0,
  86. products: [{
  87. bizPrice: 0,
  88. buyNum: 0,
  89. imgUrl: '',
  90. originalPrice: 0,
  91. productId: 0,
  92. productName: '',
  93. productType: 0,
  94. shoppingcartId: 0,
  95. tenantCode: ''
  96. }],
  97. supplierName: '',
  98. tenantCode: ''
  99. }
  100. },
  101. },
  102. data() {
  103. return {
  104. show_qx:true,
  105. pickHandle: false,
  106. sharePlant: false,
  107. modalShow: false,
  108. modalContent: '',
  109. handleType: '',
  110. goodType: ''
  111. }
  112. },
  113. onReady() {
  114. this.pickHandle = this.orderData.products.filter(site => site.productType == 3).length > 0
  115. this.sharePlant = this.orderData.products.filter(site => site.productType == 4).length > 0
  116. this.goodType = this.pickHandle ? 3 : ''
  117. },
  118. methods: {
  119. closeSetting:function(){
  120. this.show_qx=true;
  121. },
  122. // 跳转商铺
  123. gotoShop() {
  124. if (this.orderData.tenantCode != 'admin') {
  125. if (this.orderData.products.length) {
  126. uni.navigateTo({
  127. url: '/pagesGood/shopDetails?goodId=' + this.orderData.products[0].productId
  128. });
  129. }
  130. }
  131. },
  132. // 获取订单总价
  133. getAllPrice() {
  134. let price = this.orderData.products.reduce((total, site) => {
  135. return total + site.bizPrice * site.buyNum
  136. }, 0)
  137. return price.toFixed(2)
  138. },
  139. // 获取订单类型
  140. getOrderType(type) {
  141. switch (type) {
  142. case 1:
  143. return '待付款'
  144. break;
  145. case 2:
  146. return '待发货'
  147. break;
  148. case 3:
  149. return '已发货'
  150. break;
  151. case 4:
  152. return '已收货'
  153. break;
  154. case 5:
  155. return '已完成'
  156. break;
  157. default:
  158. return '已取消'
  159. }
  160. },
  161. // 获取拍卖状态
  162. getAuctionType(type, orderStatus) {
  163. switch (type) {
  164. case 1:
  165. return '竞拍中'
  166. break;
  167. case 2:
  168. return '竞拍成功' + '-' + this.getOrderType(orderStatus)
  169. break;
  170. case 3:
  171. return '竞拍失败'
  172. break;
  173. }
  174. },
  175. // 操作区分
  176. handleOrder(type) {
  177. if (type == 1 || type == 2 || type == 5) {
  178. this.modalContent = type == 1 ? '请确定是否取消订单' : (type == 2 ? '请确定是否立即支付' : '请确定是否确认收货')
  179. this.handleType = type
  180. this.modalShow = true
  181. } else if (type == 3) {
  182. // 申请售后
  183. NET.request(API.applyService, {
  184. tenantCode: this.orderData.tenantCode
  185. }, 'GET').then(res => {
  186. uni.makePhoneCall({
  187. phoneNumber: res.data.contactTel
  188. });
  189. }).catch(error => {
  190. this.$refs.uTips.show({
  191. title: error.data.msg,
  192. type: 'warning',
  193. })
  194. })
  195. } else if (type == 4) {
  196. // 自助采摘
  197. var that=this;
  198. if(uni.getStorageSync("firstTimeLiveUser")==""){
  199. uni.setStorage({
  200. key: 'firstTimeLiveUser',
  201. data: 1
  202. })
  203. uni.navigateTo({
  204. url: '/pagesGood/pickVideo?orderId=' + that.orderData.orderId + '&tenantCode=' + that.orderData.tenantCode
  205. });
  206. }else{
  207. wx.getSetting({
  208. success(res) {
  209. /*if (!res.authSetting['scope.camera']){
  210. that.show_qx=false;
  211. }else*/
  212. if (!res.authSetting['scope.record']){
  213. that.show_qx=false;
  214. }else{
  215. uni.navigateTo({
  216. url: '/pagesGood/pickVideo?orderId=' + that.orderData.orderId + '&tenantCode=' + that.orderData.tenantCode
  217. });
  218. }
  219. }
  220. })
  221. }
  222. return false;
  223. } else if (type == 6) {
  224. // 追踪物流
  225. uni.navigateTo({
  226. url: '/pagesMain/logisticsDeatil?logisticCode=' + this.orderData.logisticsNum
  227. });
  228. } else if (type == 7) {
  229. // 评价
  230. uni.navigateTo({
  231. url: '/pagesMain/evaluateForm?orderId=' + this.orderData.orderId + '&tenantCode=' + this.orderData.tenantCode +
  232. '&productIds=' + this.orderData.products.map(site => {
  233. return site.productId
  234. }).join(',')
  235. });
  236. } else if (type == 8) {
  237. // 去我的种植
  238. uni.navigateTo({
  239. url: '/pagesGood/goodDetails?minePlant=true&goodId=' + this.orderData.products[0].productId + '&orderId=' + this.orderData.orderId
  240. });
  241. }
  242. },
  243. // 跳转订单详情
  244. goToOrderDetail() {
  245. uni.navigateTo({
  246. url: '/pagesMain/orderDetail?orderId=' + this.orderData.orderId + '&orderStatus=' + this.orderData.orderStatus
  247. });
  248. },
  249. // 状态流转
  250. submitHandle() {
  251. if (this.handleType == 1) {
  252. // 取消订单
  253. NET.request(API.cancelOrder, {
  254. orderId: this.orderData.orderId
  255. }, 'GET').then(res => {
  256. this.modalShow = false
  257. this.$emit('reasetList');
  258. this.$refs.uTips.show({
  259. title: '取消订单成功',
  260. type: 'success',
  261. })
  262. }).catch(error => {
  263. this.modalShow = false
  264. this.$refs.uTips.show({
  265. title: error.data.msg,
  266. type: 'warning',
  267. })
  268. })
  269. } else if (this.handleType == 2) {
  270. // 立即支付
  271. NET.request(API.payOrder, {
  272. mid: uni.getStorageSync("userData").userId,
  273. orderCode: this.orderData.orderCode,
  274. orderId: this.orderData.orderId,
  275. }, 'POST').then(res => {
  276. this.modalShow = false
  277. uni.requestPayment({
  278. provider: 'wxpay',
  279. timeStamp: res.data.timeStamp,
  280. nonceStr: res.data.nonceStr,
  281. package: res.data.packageValue,
  282. signType: res.data.signType,
  283. paySign: res.data.paySign,
  284. success: (payRes) => {
  285. console.log('success:' + JSON.stringify(payRes));
  286. // if (this.goodType == 3) {
  287. // uni.navigateTo({
  288. // url: '/pagesMain/paySuccess?orderId=' + this.orderData.orderId + '&goodType=' + this.goodType + '&tenantCode=' + this.orderData.tenantCode
  289. // });
  290. // } else {
  291. uni.navigateTo({
  292. url: '/pagesMain/paySuccess?orderId=' + this.orderData.orderId
  293. });
  294. // }
  295. },
  296. fail: (error) => {
  297. console.log('fail:' + JSON.stringify(error));
  298. this.$refs.uTips.show({
  299. title: '支付失败',
  300. type: 'warning',
  301. })
  302. }
  303. })
  304. }).catch(error => {
  305. this.modalShow = false
  306. this.$refs.uTips.show({
  307. title: error.data.msg,
  308. type: 'warning',
  309. })
  310. })
  311. } else if (this.handleType == 5) {
  312. // 确认收货
  313. NET.request(API.confirmOrder, {
  314. orderId: this.orderData.orderId
  315. }, 'GET').then(res => {
  316. this.modalShow = false
  317. this.$emit('reasetList');
  318. this.$refs.uTips.show({
  319. title: '确认收货成功',
  320. type: 'success',
  321. })
  322. }).catch(error => {
  323. this.modalShow = false
  324. this.$refs.uTips.show({
  325. title: error.data.msg,
  326. type: 'warning',
  327. })
  328. })
  329. }
  330. },
  331. }
  332. }
  333. </script>
  334. <style>
  335. </style>
  336. <style lang="less" scoped>
  337. .order-row {
  338. width: 100%;
  339. float: left;
  340. margin: 0 0 15px 0;
  341. background: #FFFFFF;
  342. border-radius: 10px;
  343. .shop-info {
  344. width: 100%;
  345. height: 48px;
  346. float: left;
  347. box-sizing: border-box;
  348. padding: 13px 15px 12px 15px;
  349. border-bottom: 1px solid #EEEEEE;
  350. line-height: 22px;
  351. .icondianpu {
  352. font-size: 22px;
  353. color: #333333;
  354. }
  355. .shop-name {
  356. font-size: 15px;
  357. font-family: PingFang SC;
  358. color: #333333;
  359. margin: 0 8px 0 10px;
  360. }
  361. .iconshangjia {
  362. font-size: 12px;
  363. color: #999999;
  364. }
  365. .order-type {
  366. float: right;
  367. font-size: 15px;
  368. font-family: PingFang SC;
  369. color: #52A63A;
  370. }
  371. }
  372. .goods-list {
  373. width: 100%;
  374. float: left;
  375. box-sizing: border-box;
  376. padding: 10px 15px 0 15px;
  377. .goods-row {
  378. width: 100%;
  379. height: 90px;
  380. float: left;
  381. display: flex;
  382. margin-bottom: 10px;
  383. .goods-img {
  384. width: 90px;
  385. height: 90px;
  386. border-radius: 5px;
  387. object-fit: cover;
  388. }
  389. .goods-info {
  390. width: calc(100% - 106px);
  391. height: 90px;
  392. margin-left: 16px;
  393. .goods-name {
  394. width: 100%;
  395. height: 36px;
  396. float: left;
  397. font-size: 14px;
  398. font-family: PingFang SC;
  399. color: #333333;
  400. line-height: 18px;
  401. overflow: hidden;
  402. text-overflow: ellipsis;
  403. display: -webkit-box;
  404. -webkit-line-clamp: 2;
  405. -webkit-box-orient: vertical;
  406. word-wrap: break-word;
  407. }
  408. .goods-type {
  409. height: 20px;
  410. float: left;
  411. background: #F0F0F0;
  412. border-radius: 4px;
  413. padding: 0 8px;
  414. margin: 6px 0;
  415. font-size: 10px;
  416. font-family: PingFang SC;
  417. color: #666666;
  418. line-height: 20px;
  419. }
  420. .goods-price-number {
  421. width: 100%;
  422. height: 20px;
  423. float: left;
  424. line-height: 20px;
  425. font-family: PingFang SC;
  426. color: #333333;
  427. .goods-unit {
  428. font-size: 12px;
  429. }
  430. .goods-price {
  431. font-size: 15px;
  432. margin-right: 6px;
  433. }
  434. .goods-number {
  435. font-size: 12px;
  436. }
  437. }
  438. }
  439. }
  440. }
  441. .pay-info {
  442. width: 100%;
  443. float: left;
  444. box-sizing: border-box;
  445. padding: 20px 15px 16px 15px;
  446. font-size: 12px;
  447. font-family: PingFang SC;
  448. color: #333333;
  449. line-height: 16px;
  450. text-align: right;
  451. }
  452. .handle-box {
  453. width: calc(100% - 30px);
  454. float: left;
  455. margin: 0 15px;
  456. box-sizing: border-box;
  457. padding: 10px 0 0 0;
  458. border-top: 1px solid #EEEEEE;
  459. text-align: right;
  460. .handle-button {
  461. height: 30px;
  462. margin-left: 8px;
  463. margin-bottom: 10px;
  464. line-height: 28px;
  465. text-align: center;
  466. box-sizing: border-box;
  467. display: inline-block;
  468. border-radius: 15px;
  469. /deep/button {
  470. padding: 0 12px;
  471. border: 1px solid #BFBFBF !important;
  472. background-color: #FFFFFF!important;
  473. color: #333333 !important;
  474. }
  475. }
  476. }
  477. }
  478. /deep/.u-size-medium {
  479. padding: 0 12px;
  480. }
  481. /deep/.u-round-circle {
  482. padding: 0 12px;
  483. }
  484. .uni-popup-dialog {
  485. width: 80vw;
  486. border-radius: 15px;
  487. background-color: #fff;
  488. position: fixed;
  489. margin-left: 10vw;
  490. top: 34vh;
  491. z-index: 11;
  492. left: 0px;
  493. }
  494. .uni-dialog-title {
  495. /* #ifndef APP-NVUE */
  496. display: flex;
  497. /* #endif */
  498. flex-direction: row;
  499. justify-content: center;
  500. padding-top: 15px;
  501. padding-bottom: 5px;
  502. }
  503. .uni-dialog-title-text {
  504. font-size: 16px;
  505. font-weight: 500;
  506. }
  507. .uni-dialog-content {
  508. /* #ifndef APP-NVUE */
  509. display: flex;
  510. /* #endif */
  511. flex-direction: row;
  512. justify-content: center;
  513. align-items: center;
  514. padding: 5px 15px 15px 15px;
  515. text-align: center;
  516. }
  517. .uni-dialog-content-text {
  518. font-size: 14px;
  519. color: #6e6e6e;
  520. }
  521. .uni-dialog-button-group {
  522. /* #ifndef APP-NVUE */
  523. display: flex;
  524. /* #endif */
  525. flex-direction: row;
  526. border-top-color: #f5f5f5;
  527. border-top-style: solid;
  528. border-top-width: 1px;
  529. }
  530. .uni-dialog-button {
  531. /* #ifndef APP-NVUE */
  532. display: flex;
  533. /* #endif */
  534. background: rgba(0, 0, 0, 0);
  535. border: none;
  536. flex: 1;
  537. flex-direction: row;
  538. justify-content: center;
  539. align-items: center;
  540. height: 45px;
  541. }
  542. .uni-border-left {
  543. border-left-color: #f0f0f0;
  544. border-left-style: solid;
  545. border-left-width: 0px;
  546. }
  547. .uni-dialog-button-text {
  548. font-size: 14px;
  549. }
  550. .uni-button-color {
  551. color: #007aff;
  552. }
  553. .uni-dialog-input {
  554. flex: 1;
  555. font-size: 14px;
  556. }
  557. .uni-popup__success {
  558. color: #4cd964;
  559. }
  560. .uni-popup__warn {
  561. color: #f0ad4e;
  562. }
  563. .uni-popup__error {
  564. color: #dd524d;
  565. }
  566. .uni-popup__info {
  567. color: #909399;
  568. }
  569. .qx_bg{
  570. width: 100vw;
  571. height: 100vh;
  572. background: rgba(0, 0, 0, 0.25);
  573. position: fixed;
  574. top: 0px;
  575. left: 0px;
  576. z-index: 10;
  577. }
  578. </style>