orderItem.vue 14 KB

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