orderItem.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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 == 4" @click.stop="handleOrder(5)">确认收货</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" @click.stop="handleOrder(6)">追踪物流</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 == 5 && orderData.evaluateStatus == 1" @click.stop="handleOrder(7)">评价</u-button>
  42. </view>
  43. <u-modal v-model="modalShow" :content="modalContent" @confirm="submitHandle" :async-close="true" :show-cancel-button="true"></u-modal>
  44. <u-top-tips ref="uTips"></u-top-tips>
  45. </view>
  46. <view class="uni-popup-dialog" :hidden="show_qx">
  47. <view class="uni-dialog-title">
  48. <text class="uni-dialog-title-text">提示</text>
  49. </view>
  50. <view class="uni-dialog-content">
  51. <text class="uni-dialog-content-text">请在设置中开启摄像头权限和麦克风权限</text>
  52. </view>
  53. <view class="uni-dialog-button-group">
  54. <button class="uni-dialog-button uni-border-left" open-type="openSetting" @click="closeSetting">
  55. 设置权限
  56. </button>
  57. </view>
  58. </view>
  59. <view class="qx_bg" :hidden="show_qx">
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. const NET = require('@/utils/request')
  65. const API = require('@/config/api')
  66. export default {
  67. props: {
  68. tabIndex: {
  69. default: 1
  70. },
  71. orderData: {
  72. default: {
  73. auctionStatus: 0,
  74. orderId: 0,
  75. orderStatus: 0,
  76. evaluateReplyStatus: 0,
  77. nickname: '',
  78. payStatus: 0,
  79. paySum: 0,
  80. products: [{
  81. bizPrice: 0,
  82. buyNum: 0,
  83. imgUrl: '',
  84. originalPrice: 0,
  85. productId: 0,
  86. productName: '',
  87. productType: 0,
  88. shoppingcartId: 0,
  89. tenantCode: ''
  90. }],
  91. supplierName: '',
  92. tenantCode: ''
  93. }
  94. },
  95. },
  96. data() {
  97. return {
  98. show_qx:true,
  99. pickHandle: false,
  100. modalShow: false,
  101. modalContent: '',
  102. handleType: '',
  103. }
  104. },
  105. onReady() {
  106. this.pickHandle = this.orderData.products.filter(site => site.productType == 3).length > 0
  107. },
  108. methods: {
  109. closeSetting:function(){
  110. this.show_qx=true;
  111. },
  112. // 跳转商铺
  113. gotoShop() {
  114. if (this.orderData.tenantCode != 'admin') {
  115. if (this.orderData.products.length) {
  116. uni.navigateTo({
  117. url: '/pagesGood/shopDetails?goodId=' + this.orderData.products[0].productId
  118. });
  119. }
  120. }
  121. },
  122. // 获取订单总价
  123. getAllPrice() {
  124. let price = this.orderData.products.reduce((total, site) => {
  125. return total + site.bizPrice * site.buyNum
  126. }, 0)
  127. return price.toFixed(2)
  128. },
  129. // 获取订单类型
  130. getOrderType(type) {
  131. switch (type) {
  132. case 1:
  133. return '待付款'
  134. break;
  135. case 2:
  136. return '待发货'
  137. break;
  138. case 3:
  139. return '已发货'
  140. break;
  141. case 4:
  142. return '已收货'
  143. break;
  144. case 5:
  145. return '已完成'
  146. break;
  147. default:
  148. return '已取消'
  149. }
  150. },
  151. // 获取拍卖状态
  152. getAuctionType(type, orderStatus) {
  153. switch (type) {
  154. case 1:
  155. return '竞拍中'
  156. break;
  157. case 2:
  158. return '竞拍成功' + '-' + this.getOrderType(orderStatus)
  159. break;
  160. case 3:
  161. return '竞拍失败'
  162. break;
  163. }
  164. },
  165. // 操作区分
  166. handleOrder(type) {
  167. if (type == 1 || type == 2 || type == 5) {
  168. this.modalContent = type == 1 ? '请确定是否取消订单' : (type == 2 ? '请确定是否立即支付' : '请确定是否确认收货')
  169. this.handleType = type
  170. this.modalShow = true
  171. } else if (type == 3) {
  172. // 申请售后
  173. NET.request(API.applyService, {
  174. tenantCode: this.orderData.tenantCode
  175. }, 'GET').then(res => {
  176. uni.makePhoneCall({
  177. phoneNumber: res.data.contactTel
  178. });
  179. }).catch(error => {
  180. this.$refs.uTips.show({
  181. title: error.data.msg,
  182. type: 'warning',
  183. })
  184. })
  185. } else if (type == 4) {
  186. // 自助采摘
  187. var that=this;
  188. wx.getSetting({
  189. success(res) {
  190. if (!res.authSetting['scope.camera']){
  191. that.show_qx=false;
  192. }else if (!res.authSetting['scope.record']){
  193. that.show_qx=false;
  194. }else{
  195. uni.navigateTo({
  196. url: '/pagesGood/pickVideo?orderId=' + that.orderData.orderId + '&tenantCode=' + that.orderData.tenantCode
  197. });
  198. }
  199. }
  200. })
  201. return false;
  202. } else if (type == 6) {
  203. // 追踪物流
  204. uni.navigateTo({
  205. url: '/pagesMain/logisticsDeatil?logisticCode=' + this.orderData.logisticsNum
  206. });
  207. } else if (type == 7) {
  208. // 评价
  209. uni.navigateTo({
  210. url: '/pagesMain/evaluateForm?orderId=' + this.orderData.orderId + '&tenantCode=' + this.orderData.tenantCode +
  211. '&productIds=' + this.orderData.products.map(site => {
  212. return site.productId
  213. }).join(',')
  214. });
  215. }
  216. },
  217. // 跳转订单详情
  218. goToOrderDetail() {
  219. uni.navigateTo({
  220. url: '/pagesMain/orderDetail?orderId=' + this.orderData.orderId + '&orderStatus=' + this.orderData.orderStatus
  221. });
  222. },
  223. // 状态流转
  224. submitHandle() {
  225. if (this.handleType == 1) {
  226. // 取消订单
  227. NET.request(API.cancelOrder, {
  228. orderId: this.orderData.orderId
  229. }, 'GET').then(res => {
  230. this.modalShow = false
  231. this.$emit('reasetList');
  232. this.$refs.uTips.show({
  233. title: '取消订单成功',
  234. type: 'success',
  235. })
  236. }).catch(error => {
  237. this.modalShow = false
  238. this.$refs.uTips.show({
  239. title: error.data.msg,
  240. type: 'warning',
  241. })
  242. })
  243. } else if (this.handleType == 2) {
  244. // 立即支付
  245. NET.request(API.payOrder, {
  246. mid: uni.getStorageSync("userData").userId,
  247. orderCode: this.orderData.orderCode,
  248. orderId: this.orderData.orderId,
  249. }, 'POST').then(res => {
  250. this.modalShow = false
  251. uni.requestPayment({
  252. provider: 'wxpay',
  253. timeStamp: res.data.timeStamp,
  254. nonceStr: res.data.nonceStr,
  255. package: res.data.packageValue,
  256. signType: res.data.signType,
  257. paySign: res.data.paySign,
  258. success: (payRes) => {
  259. console.log('success:' + JSON.stringify(payRes));
  260. uni.navigateTo({
  261. url: '/pagesMain/paySuccess?orderId=' + this.orderData.orderId
  262. });
  263. },
  264. fail: (error) => {
  265. console.log('fail:' + JSON.stringify(error));
  266. this.$refs.uTips.show({
  267. title: '支付失败',
  268. type: 'warning',
  269. })
  270. }
  271. })
  272. }).catch(error => {
  273. this.modalShow = false
  274. this.$refs.uTips.show({
  275. title: error.data.msg,
  276. type: 'warning',
  277. })
  278. })
  279. } else if (this.handleType == 5) {
  280. // 确认收货
  281. NET.request(API.confirmOrder, {
  282. orderId: this.orderData.orderId
  283. }, 'GET').then(res => {
  284. this.modalShow = false
  285. this.$emit('reasetList');
  286. this.$refs.uTips.show({
  287. title: '确认收货成功',
  288. type: 'success',
  289. })
  290. }).catch(error => {
  291. this.modalShow = false
  292. this.$refs.uTips.show({
  293. title: error.data.msg,
  294. type: 'warning',
  295. })
  296. })
  297. }
  298. },
  299. }
  300. }
  301. </script>
  302. <style>
  303. </style>
  304. <style lang="less" scoped>
  305. .order-row {
  306. width: 100%;
  307. float: left;
  308. margin: 0 0 15px 0;
  309. background: #FFFFFF;
  310. border-radius: 10px;
  311. .shop-info {
  312. width: 100%;
  313. height: 48px;
  314. float: left;
  315. box-sizing: border-box;
  316. padding: 13px 15px 12px 15px;
  317. border-bottom: 1px solid #EEEEEE;
  318. line-height: 22px;
  319. .icondianpu {
  320. font-size: 22px;
  321. color: #333333;
  322. }
  323. .shop-name {
  324. font-size: 15px;
  325. font-family: PingFang SC;
  326. color: #333333;
  327. margin: 0 8px 0 10px;
  328. }
  329. .iconshangjia {
  330. font-size: 12px;
  331. color: #999999;
  332. }
  333. .order-type {
  334. float: right;
  335. font-size: 15px;
  336. font-family: PingFang SC;
  337. color: #52A63A;
  338. }
  339. }
  340. .goods-list {
  341. width: 100%;
  342. float: left;
  343. box-sizing: border-box;
  344. padding: 10px 15px 0 15px;
  345. .goods-row {
  346. width: 100%;
  347. height: 90px;
  348. float: left;
  349. display: flex;
  350. margin-bottom: 10px;
  351. .goods-img {
  352. width: 90px;
  353. height: 90px;
  354. border-radius: 5px;
  355. object-fit: cover;
  356. }
  357. .goods-info {
  358. width: calc(100% - 106px);
  359. height: 90px;
  360. margin-left: 16px;
  361. .goods-name {
  362. width: 100%;
  363. height: 36px;
  364. float: left;
  365. font-size: 14px;
  366. font-family: PingFang SC;
  367. color: #333333;
  368. line-height: 18px;
  369. overflow: hidden;
  370. text-overflow: ellipsis;
  371. display: -webkit-box;
  372. -webkit-line-clamp: 2;
  373. -webkit-box-orient: vertical;
  374. word-wrap: break-word;
  375. }
  376. .goods-type {
  377. height: 20px;
  378. float: left;
  379. background: #F0F0F0;
  380. border-radius: 4px;
  381. padding: 0 8px;
  382. margin: 6px 0;
  383. font-size: 10px;
  384. font-family: PingFang SC;
  385. color: #666666;
  386. line-height: 20px;
  387. }
  388. .goods-price-number {
  389. width: 100%;
  390. height: 20px;
  391. float: left;
  392. line-height: 20px;
  393. font-family: PingFang SC;
  394. color: #333333;
  395. .goods-unit {
  396. font-size: 12px;
  397. }
  398. .goods-price {
  399. font-size: 15px;
  400. margin-right: 6px;
  401. }
  402. .goods-number {
  403. font-size: 12px;
  404. }
  405. }
  406. }
  407. }
  408. }
  409. .pay-info {
  410. width: 100%;
  411. float: left;
  412. box-sizing: border-box;
  413. padding: 20px 15px 16px 15px;
  414. font-size: 12px;
  415. font-family: PingFang SC;
  416. color: #333333;
  417. line-height: 16px;
  418. text-align: right;
  419. }
  420. .handle-box {
  421. width: calc(100% - 30px);
  422. float: left;
  423. margin: 0 15px;
  424. box-sizing: border-box;
  425. padding: 10px 0 0 0;
  426. border-top: 1px solid #EEEEEE;
  427. text-align: right;
  428. .handle-button {
  429. height: 30px;
  430. margin-left: 8px;
  431. margin-bottom: 10px;
  432. line-height: 28px;
  433. text-align: center;
  434. box-sizing: border-box;
  435. display: inline-block;
  436. border-radius: 15px;
  437. /deep/button {
  438. padding: 0 12px;
  439. border: 1px solid #BFBFBF !important;
  440. background-color: #FFFFFF!important;
  441. color: #333333 !important;
  442. }
  443. }
  444. }
  445. }
  446. /deep/.u-size-medium {
  447. padding: 0 12px;
  448. }
  449. /deep/.u-round-circle {
  450. padding: 0 12px;
  451. }
  452. .uni-popup-dialog {
  453. width: 80vw;
  454. border-radius: 15px;
  455. background-color: #fff;
  456. position: fixed;
  457. margin-left: 10vw;
  458. top: 34vh;
  459. z-index: 11;
  460. left: 0px;
  461. }
  462. .uni-dialog-title {
  463. /* #ifndef APP-NVUE */
  464. display: flex;
  465. /* #endif */
  466. flex-direction: row;
  467. justify-content: center;
  468. padding-top: 15px;
  469. padding-bottom: 5px;
  470. }
  471. .uni-dialog-title-text {
  472. font-size: 16px;
  473. font-weight: 500;
  474. }
  475. .uni-dialog-content {
  476. /* #ifndef APP-NVUE */
  477. display: flex;
  478. /* #endif */
  479. flex-direction: row;
  480. justify-content: center;
  481. align-items: center;
  482. padding: 5px 15px 15px 15px;
  483. text-align: center;
  484. }
  485. .uni-dialog-content-text {
  486. font-size: 14px;
  487. color: #6e6e6e;
  488. }
  489. .uni-dialog-button-group {
  490. /* #ifndef APP-NVUE */
  491. display: flex;
  492. /* #endif */
  493. flex-direction: row;
  494. border-top-color: #f5f5f5;
  495. border-top-style: solid;
  496. border-top-width: 1px;
  497. }
  498. .uni-dialog-button {
  499. /* #ifndef APP-NVUE */
  500. display: flex;
  501. /* #endif */
  502. background: rgba(0, 0, 0, 0);
  503. border: none;
  504. flex: 1;
  505. flex-direction: row;
  506. justify-content: center;
  507. align-items: center;
  508. height: 45px;
  509. }
  510. .uni-border-left {
  511. border-left-color: #f0f0f0;
  512. border-left-style: solid;
  513. border-left-width: 0px;
  514. }
  515. .uni-dialog-button-text {
  516. font-size: 14px;
  517. }
  518. .uni-button-color {
  519. color: #007aff;
  520. }
  521. .uni-dialog-input {
  522. flex: 1;
  523. font-size: 14px;
  524. }
  525. .uni-popup__success {
  526. color: #4cd964;
  527. }
  528. .uni-popup__warn {
  529. color: #f0ad4e;
  530. }
  531. .uni-popup__error {
  532. color: #dd524d;
  533. }
  534. .uni-popup__info {
  535. color: #909399;
  536. }
  537. .qx_bg{
  538. width: 100vw;
  539. height: 100vh;
  540. background: rgba(0, 0, 0, 0.25);
  541. position: fixed;
  542. top: 0px;
  543. left: 0px;
  544. z-index: 10;
  545. }
  546. </style>