orderItem.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <view class="order-row" @click="goToOrderDetail()">
  3. <view class="shop-info" v-if="orderData" @click="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
  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 lang="less" scoped>
  268. .order-row {
  269. width: 100%;
  270. float: left;
  271. margin: 0 0 15px 0;
  272. background: #FFFFFF;
  273. border-radius: 10px;
  274. .shop-info {
  275. width: 100%;
  276. height: 48px;
  277. float: left;
  278. box-sizing: border-box;
  279. padding: 13px 15px 12px 15px;
  280. border-bottom: 1px solid #EEEEEE;
  281. line-height: 22px;
  282. .icondianpu {
  283. font-size: 22px;
  284. color: #333333;
  285. }
  286. .shop-name {
  287. font-size: 15px;
  288. font-family: PingFang SC;
  289. color: #333333;
  290. margin: 0 8px 0 10px;
  291. }
  292. .iconshangjia {
  293. font-size: 12px;
  294. color: #999999;
  295. }
  296. .order-type {
  297. float: right;
  298. font-size: 15px;
  299. font-family: PingFang SC;
  300. color: #52A63A;
  301. }
  302. }
  303. .goods-list {
  304. width: 100%;
  305. float: left;
  306. box-sizing: border-box;
  307. padding: 10px 15px 0 15px;
  308. .goods-row {
  309. width: 100%;
  310. height: 90px;
  311. float: left;
  312. display: flex;
  313. margin-bottom: 10px;
  314. .goods-img {
  315. width: 90px;
  316. height: 90px;
  317. border-radius: 5px;
  318. object-fit: cover;
  319. }
  320. .goods-info {
  321. width: calc(100% - 106px);
  322. height: 90px;
  323. margin-left: 16px;
  324. .goods-name {
  325. width: 100%;
  326. height: 36px;
  327. float: left;
  328. font-size: 14px;
  329. font-family: PingFang SC;
  330. color: #333333;
  331. line-height: 18px;
  332. overflow: hidden;
  333. text-overflow: ellipsis;
  334. display: -webkit-box;
  335. -webkit-line-clamp: 2;
  336. -webkit-box-orient: vertical;
  337. word-wrap: break-word;
  338. }
  339. .goods-type {
  340. height: 20px;
  341. float: left;
  342. background: #F0F0F0;
  343. border-radius: 4px;
  344. padding: 0 8px;
  345. margin: 6px 0;
  346. font-size: 10px;
  347. font-family: PingFang SC;
  348. color: #666666;
  349. line-height: 20px;
  350. }
  351. .goods-price-number {
  352. width: 100%;
  353. height: 20px;
  354. float: left;
  355. line-height: 20px;
  356. font-family: PingFang SC;
  357. color: #333333;
  358. .goods-unit {
  359. font-size: 12px;
  360. }
  361. .goods-price {
  362. font-size: 15px;
  363. margin-right: 6px;
  364. }
  365. .goods-number {
  366. font-size: 12px;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. .pay-info {
  373. width: 100%;
  374. float: left;
  375. box-sizing: border-box;
  376. padding: 20px 15px 16px 15px;
  377. font-size: 12px;
  378. font-family: PingFang SC;
  379. color: #333333;
  380. line-height: 16px;
  381. text-align: right;
  382. }
  383. .handle-box {
  384. width: calc(100% - 30px);
  385. float: left;
  386. margin: 0 15px;
  387. box-sizing: border-box;
  388. padding: 10px 0 0 0;
  389. border-top: 1px solid #EEEEEE;
  390. text-align: right;
  391. .handle-button {
  392. color: #333333 !important;
  393. border-color: #BFBFBF !important;
  394. background-color: #FFFFFF !important;
  395. padding: 0;
  396. margin-left: 8px;
  397. margin-bottom: 10px;
  398. height: 30px;
  399. line-height: 30px;
  400. display: inline-block;
  401. }
  402. }
  403. }
  404. /deep/.u-size-medium {
  405. padding: 0 12px;
  406. }
  407. /deep/.u-round-circle {
  408. padding: 0 12px;
  409. }
  410. </style>