orderItem.vue 11 KB

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