orderItem.vue 17 KB

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