orderItem.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <template>
  2. <view>
  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. mounted() {
  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. // #ifdef MP-WEIXIN
  198. var that = this;
  199. if (uni.getStorageSync("firstTimeLiveUser") == "") {
  200. uni.setStorage({
  201. key: 'firstTimeLiveUser',
  202. data: 1
  203. })
  204. uni.navigateTo({
  205. url: '/pagesGood/pickVideo?orderId=' + that.orderData.orderId + '&tenantCode=' + that.orderData.tenantCode
  206. });
  207. } else {
  208. wx.getSetting({
  209. success(res) {
  210. /*if (!res.authSetting['scope.camera']){
  211. that.show_qx=false;
  212. }else*/
  213. if (!res.authSetting['scope.record']) {
  214. that.show_qx = false;
  215. } else {
  216. uni.navigateTo({
  217. url: '/pagesGood/pickVideo?orderId=' + that.orderData.orderId + '&tenantCode=' + that.orderData.tenantCode
  218. });
  219. }
  220. }
  221. })
  222. }
  223. return false;
  224. // #endif
  225. // #ifdef APP-PLUS
  226. uni.navigateTo({
  227. url: '/pagesGood/pickVideo?orderId=' + this.orderData.orderId + '&tenantCode=' + this.orderData.tenantCode
  228. });
  229. // #endif
  230. } else if (type == 6) {
  231. // 追踪物流
  232. uni.navigateTo({
  233. url: '/pagesMain/logisticsDeatil?logisticCode=' + this.orderData.logisticsNum
  234. });
  235. } else if (type == 7) {
  236. // 评价
  237. uni.navigateTo({
  238. url: '/pagesMain/evaluateForm?orderId=' + this.orderData.orderId + '&tenantCode=' + this.orderData.tenantCode +
  239. '&productIds=' + this.orderData.products.map(site => {
  240. return site.productId
  241. }).join(',')
  242. });
  243. } else if (type == 8) {
  244. // 去我的种植
  245. uni.navigateTo({
  246. url: '/pagesGood/goodDetails?minePlant=true&goodId=' + this.orderData.products[0].productId + '&orderId=' +
  247. this.orderData.orderId
  248. });
  249. }
  250. },
  251. // 跳转订单详情
  252. goToOrderDetail() {
  253. uni.navigateTo({
  254. url: '/pagesMain/orderDetail?orderId=' + this.orderData.orderId + '&orderStatus=' + this.orderData.orderStatus
  255. });
  256. },
  257. // 状态流转
  258. submitHandle() {
  259. if (this.handleType == 1) {
  260. // 取消订单
  261. NET.request(API.cancelOrder, {
  262. orderId: this.orderData.orderId
  263. }, 'GET').then(res => {
  264. this.modalShow = false
  265. this.$emit('reasetList');
  266. this.$refs.uTips.show({
  267. title: '取消订单成功',
  268. type: 'success',
  269. })
  270. }).catch(error => {
  271. this.modalShow = false
  272. this.$refs.uTips.show({
  273. title: error.data.msg,
  274. type: 'warning',
  275. })
  276. })
  277. } else if (this.handleType == 2) {
  278. // 立即支付
  279. NET.request(API.payOrder, {
  280. mid: uni.getStorageSync("userData").userId,
  281. orderCode: this.orderData.orderCode,
  282. orderId: this.orderData.orderId,
  283. // #ifdef APP-PLUS
  284. channel: 2
  285. //#endif
  286. }, 'POST').then(res => {
  287. this.modalShow = false
  288. // #ifdef MP-WEIXIN
  289. uni.requestPayment({
  290. provider: 'wxpay',
  291. timeStamp: res.data.timeStamp,
  292. nonceStr: res.data.nonceStr,
  293. package: res.data.packageValue,
  294. signType: res.data.signType,
  295. paySign: res.data.paySign,
  296. success: (payRes) => {
  297. console.log('success:' + JSON.stringify(payRes));
  298. // if (this.goodType == 3) {
  299. // uni.navigateTo({
  300. // url: '/pagesMain/paySuccess?orderId=' + this.orderData.orderId + '&goodType=' + this.goodType + '&tenantCode=' + this.orderData.tenantCode
  301. // });
  302. // } else {
  303. uni.navigateTo({
  304. url: '/pagesMain/paySuccess?orderId=' + this.orderData.orderId
  305. });
  306. // }
  307. },
  308. fail: (error) => {
  309. console.log('fail:' + JSON.stringify(error));
  310. this.$refs.uTips.show({
  311. title: '支付失败',
  312. type: 'warning',
  313. })
  314. }
  315. })
  316. //#endif
  317. // #ifdef APP-PLUS
  318. uni.requestPayment({
  319. provider: 'wxpay',
  320. orderInfo: {
  321. "package": res.data.packageValue,
  322. "appid": res.data.appId,
  323. "sign": res.data.paySign,
  324. "partnerid": res.data.partnerId,
  325. "prepayid": res.data.prepayId,
  326. "noncestr": res.data.nonceStr,
  327. "timestamp": res.data.timeStamp,
  328. },
  329. success: (payRes) => {
  330. console.log('success:' + JSON.stringify(payRes));
  331. uni.navigateTo({
  332. url: '/pagesMain/paySuccess?orderId=' + this.orderData.orderId
  333. });
  334. },
  335. fail: (error) => {
  336. console.log('fail:' + JSON.stringify(error));
  337. this.$refs.uTips.show({
  338. title: '支付失败',
  339. type: 'warning',
  340. })
  341. }
  342. })
  343. //#endif
  344. }).catch(error => {
  345. this.modalShow = false
  346. this.$refs.uTips.show({
  347. title: error.data.msg,
  348. type: 'warning',
  349. })
  350. })
  351. } else if (this.handleType == 5) {
  352. // 确认收货
  353. NET.request(API.confirmOrder, {
  354. orderId: this.orderData.orderId
  355. }, 'GET').then(res => {
  356. this.modalShow = false
  357. this.$emit('reasetList');
  358. this.$refs.uTips.show({
  359. title: '确认收货成功',
  360. type: 'success',
  361. })
  362. }).catch(error => {
  363. this.modalShow = false
  364. this.$refs.uTips.show({
  365. title: error.data.msg,
  366. type: 'warning',
  367. })
  368. })
  369. }
  370. },
  371. }
  372. }
  373. </script>
  374. <style>
  375. </style>
  376. <style lang="less" scoped>
  377. .order-row {
  378. width: 100%;
  379. float: left;
  380. margin: 0 0 15px 0;
  381. background: #FFFFFF;
  382. border-radius: 10px;
  383. .shop-info {
  384. width: 100%;
  385. height: 48px;
  386. float: left;
  387. box-sizing: border-box;
  388. padding: 13px 15px 12px 15px;
  389. border-bottom: 1px solid #EEEEEE;
  390. line-height: 22px;
  391. .icondianpu {
  392. font-size: 22px;
  393. color: #333333;
  394. }
  395. .shop-name {
  396. font-size: 15px;
  397. font-family: PingFang SC;
  398. color: #333333;
  399. margin: 0 8px 0 10px;
  400. }
  401. .iconshangjia {
  402. font-size: 12px;
  403. color: #999999;
  404. }
  405. .order-type {
  406. float: right;
  407. font-size: 15px;
  408. font-family: PingFang SC;
  409. color: #52A63A;
  410. }
  411. }
  412. .goods-list {
  413. width: 100%;
  414. float: left;
  415. box-sizing: border-box;
  416. padding: 10px 15px 0 15px;
  417. .goods-row {
  418. width: 100%;
  419. height: 90px;
  420. float: left;
  421. display: flex;
  422. margin-bottom: 10px;
  423. .goods-img {
  424. width: 90px;
  425. height: 90px;
  426. border-radius: 5px;
  427. object-fit: cover;
  428. }
  429. .goods-info {
  430. width: calc(100% - 106px);
  431. height: 90px;
  432. margin-left: 16px;
  433. .goods-name {
  434. width: 100%;
  435. height: 36px;
  436. float: left;
  437. font-size: 14px;
  438. font-family: PingFang SC;
  439. color: #333333;
  440. line-height: 18px;
  441. overflow: hidden;
  442. text-overflow: ellipsis;
  443. display: -webkit-box;
  444. -webkit-line-clamp: 2;
  445. -webkit-box-orient: vertical;
  446. word-wrap: break-word;
  447. }
  448. .goods-type {
  449. height: 20px;
  450. float: left;
  451. background: #F0F0F0;
  452. border-radius: 4px;
  453. padding: 0 8px;
  454. margin: 6px 0;
  455. font-size: 10px;
  456. font-family: PingFang SC;
  457. color: #666666;
  458. line-height: 20px;
  459. }
  460. .goods-price-number {
  461. width: 100%;
  462. height: 20px;
  463. float: left;
  464. line-height: 20px;
  465. font-family: PingFang SC;
  466. color: #333333;
  467. .goods-unit {
  468. font-size: 12px;
  469. }
  470. .goods-price {
  471. font-size: 15px;
  472. margin-right: 6px;
  473. }
  474. .goods-number {
  475. font-size: 12px;
  476. }
  477. }
  478. }
  479. }
  480. }
  481. .pay-info {
  482. width: 100%;
  483. float: left;
  484. box-sizing: border-box;
  485. padding: 20px 15px 16px 15px;
  486. font-size: 12px;
  487. font-family: PingFang SC;
  488. color: #333333;
  489. line-height: 16px;
  490. text-align: right;
  491. }
  492. .handle-box {
  493. width: calc(100% - 30px);
  494. float: left;
  495. margin: 0 15px;
  496. box-sizing: border-box;
  497. padding: 10px 0 0 0;
  498. border-top: 1px solid #EEEEEE;
  499. text-align: right;
  500. .handle-button {
  501. height: 30px;
  502. margin-left: 8px;
  503. margin-bottom: 10px;
  504. line-height: 28px;
  505. text-align: center;
  506. box-sizing: border-box;
  507. display: inline-block;
  508. border-radius: 15px;
  509. /deep/button {
  510. padding: 0 12px;
  511. border: 1px solid #BFBFBF !important;
  512. background-color: #FFFFFF !important;
  513. color: #333333 !important;
  514. }
  515. }
  516. }
  517. }
  518. /deep/.u-size-medium {
  519. padding: 0 12px;
  520. }
  521. /deep/.u-round-circle {
  522. padding: 0 12px;
  523. }
  524. .uni-popup-dialog {
  525. width: 80vw;
  526. border-radius: 15px;
  527. background-color: #fff;
  528. position: fixed;
  529. margin-left: 10vw;
  530. top: 34vh;
  531. z-index: 11;
  532. left: 0px;
  533. }
  534. .uni-dialog-title {
  535. /* #ifndef APP-NVUE */
  536. display: flex;
  537. /* #endif */
  538. flex-direction: row;
  539. justify-content: center;
  540. padding-top: 15px;
  541. padding-bottom: 5px;
  542. }
  543. .uni-dialog-title-text {
  544. font-size: 16px;
  545. font-weight: 500;
  546. }
  547. .uni-dialog-content {
  548. /* #ifndef APP-NVUE */
  549. display: flex;
  550. /* #endif */
  551. flex-direction: row;
  552. justify-content: center;
  553. align-items: center;
  554. padding: 5px 15px 15px 15px;
  555. text-align: center;
  556. }
  557. .uni-dialog-content-text {
  558. font-size: 14px;
  559. color: #6e6e6e;
  560. }
  561. .uni-dialog-button-group {
  562. /* #ifndef APP-NVUE */
  563. display: flex;
  564. /* #endif */
  565. flex-direction: row;
  566. border-top-color: #f5f5f5;
  567. border-top-style: solid;
  568. border-top-width: 1px;
  569. }
  570. .uni-dialog-button {
  571. /* #ifndef APP-NVUE */
  572. display: flex;
  573. /* #endif */
  574. background: rgba(0, 0, 0, 0);
  575. border: none;
  576. flex: 1;
  577. flex-direction: row;
  578. justify-content: center;
  579. align-items: center;
  580. height: 45px;
  581. }
  582. .uni-border-left {
  583. border-left-color: #f0f0f0;
  584. border-left-style: solid;
  585. border-left-width: 0px;
  586. }
  587. .uni-dialog-button-text {
  588. font-size: 14px;
  589. }
  590. .uni-button-color {
  591. color: #007aff;
  592. }
  593. .uni-dialog-input {
  594. flex: 1;
  595. font-size: 14px;
  596. }
  597. .uni-popup__success {
  598. color: #4cd964;
  599. }
  600. .uni-popup__warn {
  601. color: #f0ad4e;
  602. }
  603. .uni-popup__error {
  604. color: #dd524d;
  605. }
  606. .uni-popup__info {
  607. color: #909399;
  608. }
  609. .qx_bg {
  610. width: 100vw;
  611. height: 100vh;
  612. background: rgba(0, 0, 0, 0.25);
  613. position: fixed;
  614. top: 0px;
  615. left: 0px;
  616. z-index: 10;
  617. }
  618. </style>