orderItem.vue 15 KB

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