orderItem.vue 11 KB

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