orderItem.vue 15 KB

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