orderItem.vue 17 KB

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