orderItem.vue 11 KB

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