orderItem.vue 17 KB

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