orderItem.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <view class="order-row" @click="goToOrderDetail()">
  3. <view class="shop-info" v-if="orderData" @click.stop="gotoShop()">
  4. <text class="iconfont icondianpu"></text>
  5. <text class="shop-name">{{orderData.supplierName}}</text>
  6. <text class="iconfont iconfangxiang" v-if="orderData.tenantCode != 'admin'"></text>
  7. <text class="order-type">{{orderData.auctionStatus == null ? getOrderType(orderData.orderStatus) : getAuctionType(orderData.auctionStatus,orderData.orderStatus)}}</text>
  8. </view>
  9. <view class="goods-list" v-if="orderData">
  10. <view class="goods-row" v-for="(site, index) in orderData.products" :key="index">
  11. <image class="goods-img" :src="site.imgUrl" mode="aspectFill"></image>
  12. <view class="goods-info">
  13. <view class="goods-name">{{site.productName}}</view>
  14. <view class="goods-type">
  15. 类型:{{site.productType == 1 ? '普通商品' : (site.productType == 2 ? '拍卖' : (site.productType == 3 ? '自助采摘' : '共享种植'))}}
  16. </view>
  17. <view class="goods-price-number">
  18. <text class="goods-unit">¥</text>
  19. <text class="goods-price">{{site.bizPrice}}</text>
  20. <text class="goods-number">x{{site.buyNum}}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="pay-info">总价¥{{getAllPrice()}},实付¥{{orderData.paySum}}</view>
  26. <view class="handle-box" v-if="tabIndex > 1">
  27. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  28. v-if="tabIndex == 2" @click.stop="handleOrder(1)">取消订单</u-button>
  29. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  30. v-if="tabIndex == 2" @click.stop="handleOrder(2)">立即支付</u-button>
  31. <!-- <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  32. v-if="tabIndex != 1 && tabIndex != 2" @click.stop="handleOrder(3)">申请售后</u-button> -->
  33. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  34. v-if="tabIndex == 3 && pickHandle" @click.stop="handleOrder(4)">自助采摘</u-button>
  35. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  36. v-if="tabIndex == 3 && sharePlant" @click.stop="handleOrder(8)">我的种植</u-button>
  37. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  38. v-if="tabIndex == 4 && sharePlant" @click.stop="handleOrder(8)">我的种植</u-button>
  39. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  40. v-if="tabIndex == 4" @click.stop="handleOrder(5)">确认收货</u-button>
  41. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  42. v-if="tabIndex == 4" @click.stop="handleOrder(6)">追踪物流</u-button>
  43. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  44. v-if="tabIndex == 5 && sharePlant" @click.stop="handleOrder(8)">我的种植</u-button>
  45. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  46. v-if="tabIndex == 5 && orderData.evaluateStatus == 1" @click.stop="handleOrder(7)">评价</u-button>
  47. </view>
  48. <u-modal v-model="modalShow" :content="modalContent" @confirm="submitHandle" :async-close="true" :show-cancel-button="true"></u-modal>
  49. <u-top-tips ref="uTips"></u-top-tips>
  50. </view>
  51. </template>
  52. <script>
  53. const NET = require('@/utils/request')
  54. const API = require('@/config/api')
  55. export default {
  56. props: {
  57. tabIndex: {
  58. default: 1
  59. },
  60. orderData: {
  61. default: {
  62. auctionStatus: 0,
  63. orderId: 0,
  64. orderStatus: 0,
  65. evaluateReplyStatus: 0,
  66. nickname: '',
  67. payStatus: 0,
  68. paySum: 0,
  69. products: [{
  70. bizPrice: 0,
  71. buyNum: 0,
  72. imgUrl: '',
  73. originalPrice: 0,
  74. productId: 0,
  75. productName: '',
  76. productType: 0,
  77. shoppingcartId: 0,
  78. tenantCode: ''
  79. }],
  80. supplierName: '',
  81. tenantCode: ''
  82. }
  83. },
  84. },
  85. data() {
  86. return {
  87. pickHandle: false,
  88. sharePlant: false,
  89. modalShow: false,
  90. modalContent: '',
  91. handleType: '',
  92. }
  93. },
  94. onReady() {
  95. this.pickHandle = this.orderData.products.filter(site => site.productType == 3).length > 0
  96. this.sharePlant = this.orderData.products.filter(site => site.productType == 4).length > 0
  97. },
  98. methods: {
  99. // 跳转商铺
  100. gotoShop() {
  101. if (this.orderData.tenantCode != 'admin') {
  102. if (this.orderData.products.length) {
  103. uni.navigateTo({
  104. url: '/pagesGood/shopDetails?goodId=' + this.orderData.products[0].productId
  105. });
  106. }
  107. }
  108. },
  109. // 获取订单总价
  110. getAllPrice() {
  111. let price = this.orderData.products.reduce((total, site) => {
  112. return total + site.bizPrice * site.buyNum
  113. }, 0)
  114. return price.toFixed(2)
  115. },
  116. // 获取订单类型
  117. getOrderType(type) {
  118. switch (type) {
  119. case 1:
  120. return '待付款'
  121. break;
  122. case 2:
  123. return '待发货'
  124. break;
  125. case 3:
  126. return '已发货'
  127. break;
  128. case 4:
  129. return '已收货'
  130. break;
  131. case 5:
  132. return '已完成'
  133. break;
  134. default:
  135. return '已取消'
  136. }
  137. },
  138. // 获取拍卖状态
  139. getAuctionType(type, orderStatus) {
  140. switch (type) {
  141. case 1:
  142. return '竞拍中'
  143. break;
  144. case 2:
  145. return '竞拍成功' + '-' + this.getOrderType(orderStatus)
  146. break;
  147. case 3:
  148. return '竞拍失败'
  149. break;
  150. }
  151. },
  152. // 操作区分
  153. handleOrder(type) {
  154. if (type == 1 || type == 2 || type == 5) {
  155. this.modalContent = type == 1 ? '请确定是否取消订单' : (type == 2 ? '请确定是否立即支付' : '请确定是否确认收货')
  156. this.handleType = type
  157. this.modalShow = true
  158. } else if (type == 3) {
  159. // 申请售后
  160. NET.request(API.applyService, {
  161. tenantCode: this.orderData.tenantCode
  162. }, 'GET').then(res => {
  163. uni.makePhoneCall({
  164. phoneNumber: res.data.contactTel
  165. });
  166. }).catch(error => {
  167. this.$refs.uTips.show({
  168. title: error.data.msg,
  169. type: 'warning',
  170. })
  171. })
  172. } else if (type == 4) {
  173. // 自助采摘
  174. uni.navigateTo({
  175. url: '/pagesGood/pickVideo?tenantCode=' + this.orderData.tenantCode + '&orderId=' + this.orderData.orderId
  176. });
  177. } else if (type == 6) {
  178. // 追踪物流
  179. uni.navigateTo({
  180. url: '/pagesMain/logisticsDeatil?logisticCode=' + this.orderData.logisticsNum
  181. });
  182. } else if (type == 7) {
  183. // 评价
  184. uni.navigateTo({
  185. url: '/pagesMain/evaluateForm?orderId=' + this.orderData.orderId + '&tenantCode=' + this.orderData.tenantCode +
  186. '&productIds=' + this.orderData.products.map(site => {
  187. return site.productId
  188. }).join(',')
  189. });
  190. } else if (type == 8) {
  191. // 去我的种植
  192. uni.navigateTo({
  193. url: '/pagesGood/goodDetails?minePlant=true&goodId=' + this.orderData.products[0].productId + '&orderId=' + this.orderData.orderId
  194. });
  195. }
  196. },
  197. // 跳转订单详情
  198. goToOrderDetail() {
  199. uni.navigateTo({
  200. url: '/pagesMain/orderDetail?orderId=' + this.orderData.orderId + '&orderStatus=' + this.orderData.orderStatus
  201. });
  202. },
  203. // 状态流转
  204. submitHandle() {
  205. if (this.handleType == 1) {
  206. // 取消订单
  207. NET.request(API.cancelOrder, {
  208. orderId: this.orderData.orderId
  209. }, 'GET').then(res => {
  210. this.modalShow = false
  211. this.$emit('reasetList');
  212. this.$refs.uTips.show({
  213. title: '取消订单成功',
  214. type: 'success',
  215. })
  216. }).catch(error => {
  217. this.modalShow = false
  218. this.$refs.uTips.show({
  219. title: error.data.msg,
  220. type: 'warning',
  221. })
  222. })
  223. } else if (this.handleType == 2) {
  224. // 立即支付
  225. NET.request(API.payOrder, {
  226. mid: uni.getStorageSync("userData").userId,
  227. orderCode: this.orderData.orderCode,
  228. orderId: this.orderData.orderId,
  229. }, 'POST').then(res => {
  230. this.modalShow = false
  231. uni.requestPayment({
  232. provider: 'wxpay',
  233. timeStamp: res.data.timeStamp,
  234. nonceStr: res.data.nonceStr,
  235. package: res.data.packageValue,
  236. signType: res.data.signType,
  237. paySign: res.data.paySign,
  238. success: (payRes) => {
  239. console.log('success:' + JSON.stringify(payRes));
  240. uni.navigateTo({
  241. url: '/pagesMain/paySuccess?orderId=' + this.orderData.orderId
  242. });
  243. },
  244. fail: (error) => {
  245. console.log('fail:' + JSON.stringify(error));
  246. this.$refs.uTips.show({
  247. title: '支付失败',
  248. type: 'warning',
  249. })
  250. }
  251. })
  252. }).catch(error => {
  253. this.modalShow = false
  254. this.$refs.uTips.show({
  255. title: error.data.msg,
  256. type: 'warning',
  257. })
  258. })
  259. } else if (this.handleType == 5) {
  260. // 确认收货
  261. NET.request(API.confirmOrder, {
  262. orderId: this.orderData.orderId
  263. }, 'GET').then(res => {
  264. this.modalShow = false
  265. this.$emit('reasetList');
  266. this.$refs.uTips.show({
  267. title: '确认收货成功',
  268. type: 'success',
  269. })
  270. }).catch(error => {
  271. this.modalShow = false
  272. this.$refs.uTips.show({
  273. title: error.data.msg,
  274. type: 'warning',
  275. })
  276. })
  277. }
  278. },
  279. }
  280. }
  281. </script>
  282. <style>
  283. </style>
  284. <style lang="less" scoped>
  285. .order-row {
  286. width: 100%;
  287. float: left;
  288. margin: 0 0 15px 0;
  289. background: #FFFFFF;
  290. border-radius: 10px;
  291. .shop-info {
  292. width: 100%;
  293. height: 48px;
  294. float: left;
  295. box-sizing: border-box;
  296. padding: 13px 15px 12px 15px;
  297. border-bottom: 1px solid #EEEEEE;
  298. line-height: 22px;
  299. .icondianpu {
  300. font-size: 22px;
  301. color: #333333;
  302. }
  303. .shop-name {
  304. font-size: 15px;
  305. font-family: PingFang SC;
  306. color: #333333;
  307. margin: 0 8px 0 10px;
  308. }
  309. .iconshangjia {
  310. font-size: 12px;
  311. color: #999999;
  312. }
  313. .order-type {
  314. float: right;
  315. font-size: 15px;
  316. font-family: PingFang SC;
  317. color: #52A63A;
  318. }
  319. }
  320. .goods-list {
  321. width: 100%;
  322. float: left;
  323. box-sizing: border-box;
  324. padding: 10px 15px 0 15px;
  325. .goods-row {
  326. width: 100%;
  327. height: 90px;
  328. float: left;
  329. display: flex;
  330. margin-bottom: 10px;
  331. .goods-img {
  332. width: 90px;
  333. height: 90px;
  334. border-radius: 5px;
  335. object-fit: cover;
  336. }
  337. .goods-info {
  338. width: calc(100% - 106px);
  339. height: 90px;
  340. margin-left: 16px;
  341. .goods-name {
  342. width: 100%;
  343. height: 36px;
  344. float: left;
  345. font-size: 14px;
  346. font-family: PingFang SC;
  347. color: #333333;
  348. line-height: 18px;
  349. overflow: hidden;
  350. text-overflow: ellipsis;
  351. display: -webkit-box;
  352. -webkit-line-clamp: 2;
  353. -webkit-box-orient: vertical;
  354. word-wrap: break-word;
  355. }
  356. .goods-type {
  357. height: 20px;
  358. float: left;
  359. background: #F0F0F0;
  360. border-radius: 4px;
  361. padding: 0 8px;
  362. margin: 6px 0;
  363. font-size: 10px;
  364. font-family: PingFang SC;
  365. color: #666666;
  366. line-height: 20px;
  367. }
  368. .goods-price-number {
  369. width: 100%;
  370. height: 20px;
  371. float: left;
  372. line-height: 20px;
  373. font-family: PingFang SC;
  374. color: #333333;
  375. .goods-unit {
  376. font-size: 12px;
  377. }
  378. .goods-price {
  379. font-size: 15px;
  380. margin-right: 6px;
  381. }
  382. .goods-number {
  383. font-size: 12px;
  384. }
  385. }
  386. }
  387. }
  388. }
  389. .pay-info {
  390. width: 100%;
  391. float: left;
  392. box-sizing: border-box;
  393. padding: 20px 15px 16px 15px;
  394. font-size: 12px;
  395. font-family: PingFang SC;
  396. color: #333333;
  397. line-height: 16px;
  398. text-align: right;
  399. }
  400. .handle-box {
  401. width: calc(100% - 30px);
  402. float: left;
  403. margin: 0 15px;
  404. box-sizing: border-box;
  405. padding: 10px 0 0 0;
  406. border-top: 1px solid #EEEEEE;
  407. text-align: right;
  408. .handle-button {
  409. height: 30px;
  410. margin-left: 8px;
  411. margin-bottom: 10px;
  412. line-height: 28px;
  413. text-align: center;
  414. box-sizing: border-box;
  415. display: inline-block;
  416. border-radius: 15px;
  417. /deep/button {
  418. padding: 0 12px;
  419. border: 1px solid #BFBFBF !important;
  420. background-color: #FFFFFF!important;
  421. color: #333333 !important;
  422. }
  423. }
  424. }
  425. }
  426. /deep/.u-size-medium {
  427. padding: 0 12px;
  428. }
  429. /deep/.u-round-circle {
  430. padding: 0 12px;
  431. }
  432. </style>