orderItem.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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 == 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. }
  111. },
  112. onReady() {
  113. this.pickHandle = this.orderData.products.filter(site => site.productType == 3).length > 0
  114. this.sharePlant = this.orderData.products.filter(site => site.productType == 4).length > 0
  115. },
  116. methods: {
  117. closeSetting:function(){
  118. this.show_qx=true;
  119. },
  120. // 跳转商铺
  121. gotoShop() {
  122. if (this.orderData.tenantCode != 'admin') {
  123. if (this.orderData.products.length) {
  124. uni.navigateTo({
  125. url: '/pagesGood/shopDetails?goodId=' + this.orderData.products[0].productId
  126. });
  127. }
  128. }
  129. },
  130. // 获取订单总价
  131. getAllPrice() {
  132. let price = this.orderData.products.reduce((total, site) => {
  133. return total + site.bizPrice * site.buyNum
  134. }, 0)
  135. return price.toFixed(2)
  136. },
  137. // 获取订单类型
  138. getOrderType(type) {
  139. switch (type) {
  140. case 1:
  141. return '待付款'
  142. break;
  143. case 2:
  144. return '待发货'
  145. break;
  146. case 3:
  147. return '已发货'
  148. break;
  149. case 4:
  150. return '已收货'
  151. break;
  152. case 5:
  153. return '已完成'
  154. break;
  155. default:
  156. return '已取消'
  157. }
  158. },
  159. // 获取拍卖状态
  160. getAuctionType(type, orderStatus) {
  161. switch (type) {
  162. case 1:
  163. return '竞拍中'
  164. break;
  165. case 2:
  166. return '竞拍成功' + '-' + this.getOrderType(orderStatus)
  167. break;
  168. case 3:
  169. return '竞拍失败'
  170. break;
  171. }
  172. },
  173. // 操作区分
  174. handleOrder(type) {
  175. if (type == 1 || type == 2 || type == 5) {
  176. this.modalContent = type == 1 ? '请确定是否取消订单' : (type == 2 ? '请确定是否立即支付' : '请确定是否确认收货')
  177. this.handleType = type
  178. this.modalShow = true
  179. } else if (type == 3) {
  180. // 申请售后
  181. NET.request(API.applyService, {
  182. tenantCode: this.orderData.tenantCode
  183. }, 'GET').then(res => {
  184. uni.makePhoneCall({
  185. phoneNumber: res.data.contactTel
  186. });
  187. }).catch(error => {
  188. this.$refs.uTips.show({
  189. title: error.data.msg,
  190. type: 'warning',
  191. })
  192. })
  193. } else if (type == 4) {
  194. // 自助采摘
  195. var that=this;
  196. if(uni.getStorageSync("firstTimeLiveUser")==""){
  197. uni.setStorage({
  198. key: 'firstTimeLiveUser',
  199. data: 1
  200. })
  201. uni.navigateTo({
  202. url: '/pagesGood/pickVideo?orderId=' + that.orderData.orderId + '&tenantCode=' + that.orderData.tenantCode
  203. });
  204. }else{
  205. wx.getSetting({
  206. success(res) {
  207. if (!res.authSetting['scope.camera']){
  208. that.show_qx=false;
  209. }else if (!res.authSetting['scope.record']){
  210. that.show_qx=false;
  211. }else{
  212. uni.navigateTo({
  213. url: '/pagesGood/pickVideo?orderId=' + that.orderData.orderId + '&tenantCode=' + that.orderData.tenantCode
  214. });
  215. }
  216. }
  217. })
  218. }
  219. return false;
  220. } else if (type == 6) {
  221. // 追踪物流
  222. uni.navigateTo({
  223. url: '/pagesMain/logisticsDeatil?logisticCode=' + this.orderData.logisticsNum
  224. });
  225. } else if (type == 7) {
  226. // 评价
  227. uni.navigateTo({
  228. url: '/pagesMain/evaluateForm?orderId=' + this.orderData.orderId + '&tenantCode=' + this.orderData.tenantCode +
  229. '&productIds=' + this.orderData.products.map(site => {
  230. return site.productId
  231. }).join(',')
  232. });
  233. } else if (type == 8) {
  234. // 去我的种植
  235. uni.navigateTo({
  236. url: '/pagesGood/goodDetails?minePlant=true&goodId=' + this.orderData.products[0].productId + '&orderId=' + 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. }, 'POST').then(res => {
  273. this.modalShow = false
  274. uni.requestPayment({
  275. provider: 'wxpay',
  276. timeStamp: res.data.timeStamp,
  277. nonceStr: res.data.nonceStr,
  278. package: res.data.packageValue,
  279. signType: res.data.signType,
  280. paySign: res.data.paySign,
  281. success: (payRes) => {
  282. console.log('success:' + JSON.stringify(payRes));
  283. uni.navigateTo({
  284. url: '/pagesMain/paySuccess?orderId=' + this.orderData.orderId
  285. });
  286. },
  287. fail: (error) => {
  288. console.log('fail:' + JSON.stringify(error));
  289. this.$refs.uTips.show({
  290. title: '支付失败',
  291. type: 'warning',
  292. })
  293. }
  294. })
  295. }).catch(error => {
  296. this.modalShow = false
  297. this.$refs.uTips.show({
  298. title: error.data.msg,
  299. type: 'warning',
  300. })
  301. })
  302. } else if (this.handleType == 5) {
  303. // 确认收货
  304. NET.request(API.confirmOrder, {
  305. orderId: this.orderData.orderId
  306. }, 'GET').then(res => {
  307. this.modalShow = false
  308. this.$emit('reasetList');
  309. this.$refs.uTips.show({
  310. title: '确认收货成功',
  311. type: 'success',
  312. })
  313. }).catch(error => {
  314. this.modalShow = false
  315. this.$refs.uTips.show({
  316. title: error.data.msg,
  317. type: 'warning',
  318. })
  319. })
  320. }
  321. },
  322. }
  323. }
  324. </script>
  325. <style>
  326. </style>
  327. <style lang="less" scoped>
  328. .order-row {
  329. width: 100%;
  330. float: left;
  331. margin: 0 0 15px 0;
  332. background: #FFFFFF;
  333. border-radius: 10px;
  334. .shop-info {
  335. width: 100%;
  336. height: 48px;
  337. float: left;
  338. box-sizing: border-box;
  339. padding: 13px 15px 12px 15px;
  340. border-bottom: 1px solid #EEEEEE;
  341. line-height: 22px;
  342. .icondianpu {
  343. font-size: 22px;
  344. color: #333333;
  345. }
  346. .shop-name {
  347. font-size: 15px;
  348. font-family: PingFang SC;
  349. color: #333333;
  350. margin: 0 8px 0 10px;
  351. }
  352. .iconshangjia {
  353. font-size: 12px;
  354. color: #999999;
  355. }
  356. .order-type {
  357. float: right;
  358. font-size: 15px;
  359. font-family: PingFang SC;
  360. color: #52A63A;
  361. }
  362. }
  363. .goods-list {
  364. width: 100%;
  365. float: left;
  366. box-sizing: border-box;
  367. padding: 10px 15px 0 15px;
  368. .goods-row {
  369. width: 100%;
  370. height: 90px;
  371. float: left;
  372. display: flex;
  373. margin-bottom: 10px;
  374. .goods-img {
  375. width: 90px;
  376. height: 90px;
  377. border-radius: 5px;
  378. object-fit: cover;
  379. }
  380. .goods-info {
  381. width: calc(100% - 106px);
  382. height: 90px;
  383. margin-left: 16px;
  384. .goods-name {
  385. width: 100%;
  386. height: 36px;
  387. float: left;
  388. font-size: 14px;
  389. font-family: PingFang SC;
  390. color: #333333;
  391. line-height: 18px;
  392. overflow: hidden;
  393. text-overflow: ellipsis;
  394. display: -webkit-box;
  395. -webkit-line-clamp: 2;
  396. -webkit-box-orient: vertical;
  397. word-wrap: break-word;
  398. }
  399. .goods-type {
  400. height: 20px;
  401. float: left;
  402. background: #F0F0F0;
  403. border-radius: 4px;
  404. padding: 0 8px;
  405. margin: 6px 0;
  406. font-size: 10px;
  407. font-family: PingFang SC;
  408. color: #666666;
  409. line-height: 20px;
  410. }
  411. .goods-price-number {
  412. width: 100%;
  413. height: 20px;
  414. float: left;
  415. line-height: 20px;
  416. font-family: PingFang SC;
  417. color: #333333;
  418. .goods-unit {
  419. font-size: 12px;
  420. }
  421. .goods-price {
  422. font-size: 15px;
  423. margin-right: 6px;
  424. }
  425. .goods-number {
  426. font-size: 12px;
  427. }
  428. }
  429. }
  430. }
  431. }
  432. .pay-info {
  433. width: 100%;
  434. float: left;
  435. box-sizing: border-box;
  436. padding: 20px 15px 16px 15px;
  437. font-size: 12px;
  438. font-family: PingFang SC;
  439. color: #333333;
  440. line-height: 16px;
  441. text-align: right;
  442. }
  443. .handle-box {
  444. width: calc(100% - 30px);
  445. float: left;
  446. margin: 0 15px;
  447. box-sizing: border-box;
  448. padding: 10px 0 0 0;
  449. border-top: 1px solid #EEEEEE;
  450. text-align: right;
  451. .handle-button {
  452. height: 30px;
  453. margin-left: 8px;
  454. margin-bottom: 10px;
  455. line-height: 28px;
  456. text-align: center;
  457. box-sizing: border-box;
  458. display: inline-block;
  459. border-radius: 15px;
  460. /deep/button {
  461. padding: 0 12px;
  462. border: 1px solid #BFBFBF !important;
  463. background-color: #FFFFFF!important;
  464. color: #333333 !important;
  465. }
  466. }
  467. }
  468. }
  469. /deep/.u-size-medium {
  470. padding: 0 12px;
  471. }
  472. /deep/.u-round-circle {
  473. padding: 0 12px;
  474. }
  475. .uni-popup-dialog {
  476. width: 80vw;
  477. border-radius: 15px;
  478. background-color: #fff;
  479. position: fixed;
  480. margin-left: 10vw;
  481. top: 34vh;
  482. z-index: 11;
  483. left: 0px;
  484. }
  485. .uni-dialog-title {
  486. /* #ifndef APP-NVUE */
  487. display: flex;
  488. /* #endif */
  489. flex-direction: row;
  490. justify-content: center;
  491. padding-top: 15px;
  492. padding-bottom: 5px;
  493. }
  494. .uni-dialog-title-text {
  495. font-size: 16px;
  496. font-weight: 500;
  497. }
  498. .uni-dialog-content {
  499. /* #ifndef APP-NVUE */
  500. display: flex;
  501. /* #endif */
  502. flex-direction: row;
  503. justify-content: center;
  504. align-items: center;
  505. padding: 5px 15px 15px 15px;
  506. text-align: center;
  507. }
  508. .uni-dialog-content-text {
  509. font-size: 14px;
  510. color: #6e6e6e;
  511. }
  512. .uni-dialog-button-group {
  513. /* #ifndef APP-NVUE */
  514. display: flex;
  515. /* #endif */
  516. flex-direction: row;
  517. border-top-color: #f5f5f5;
  518. border-top-style: solid;
  519. border-top-width: 1px;
  520. }
  521. .uni-dialog-button {
  522. /* #ifndef APP-NVUE */
  523. display: flex;
  524. /* #endif */
  525. background: rgba(0, 0, 0, 0);
  526. border: none;
  527. flex: 1;
  528. flex-direction: row;
  529. justify-content: center;
  530. align-items: center;
  531. height: 45px;
  532. }
  533. .uni-border-left {
  534. border-left-color: #f0f0f0;
  535. border-left-style: solid;
  536. border-left-width: 0px;
  537. }
  538. .uni-dialog-button-text {
  539. font-size: 14px;
  540. }
  541. .uni-button-color {
  542. color: #007aff;
  543. }
  544. .uni-dialog-input {
  545. flex: 1;
  546. font-size: 14px;
  547. }
  548. .uni-popup__success {
  549. color: #4cd964;
  550. }
  551. .uni-popup__warn {
  552. color: #f0ad4e;
  553. }
  554. .uni-popup__error {
  555. color: #dd524d;
  556. }
  557. .uni-popup__info {
  558. color: #909399;
  559. }
  560. .qx_bg{
  561. width: 100vw;
  562. height: 100vh;
  563. background: rgba(0, 0, 0, 0.25);
  564. position: fixed;
  565. top: 0px;
  566. left: 0px;
  567. z-index: 10;
  568. }
  569. </style>