耀实惠小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

546 lines
13 KiB

  1. <template>
  2. <view>
  3. <u-sticky>
  4. <u-tabs :list="nav_list" :is-scroll="false" :current="status" @change="getInfo" bar-width="80" active-color="#01AEEA" font-size="34"></u-tabs>
  5. </u-sticky>
  6. <!-- 待收货 -->
  7. <view class="item" v-for="(item,index) in orderList" :key="item.id">
  8. <view class="time">
  9. <text class="time_text">{{item.createTime}}</text>
  10. <text class="phone" @click="call">{{nav_list[status].name}}</text>
  11. </view>
  12. <u-read-more :toggle="true" showHeight="900" color="#6C6C6C" textIndent="0" fontSize="24rpx" closeText="展开(共5件)" openText="收起">
  13. <view class="goods_item" v-for="item2 in item.orderDetailList" @click="toGoodsInfo(item2)">
  14. <image :src="item2.goodPic2" mode="widthFix"></image>
  15. <view class="right_box">
  16. <text class="title">{{item2.goodName}}</text>
  17. <text class="title" v-if="item2.prescriptionId!=null">处方药</text>
  18. <view class="center_box">
  19. <view class="money_box">
  20. <!-- <text class="min red"></text> -->
  21. <text class="bigs red" v-if="item.payFlag !== 2">{{item2.goodPrice}}</text>
  22. <text class="bigs red" v-else>{{item2.goodPrice}}兑购</text>
  23. </view>
  24. <text class="back_money" v-if="item2.couponPrice!==0 && item2.couponPrice">再返消费金{{item2.couponPrice}}</text>
  25. <text class="back_iconx">×{{item2.goodNum}}</text>
  26. </view>
  27. <text>{{item2.goodSku}}</text>
  28. </view>
  29. </view>
  30. </u-read-more>
  31. <!-- 0要显示 订单为消费金支付是不显示 -->
  32. <text class="sum_back_momey m-l-30" v-show="item.name !== '普通订单消费金支付'">总返消费金{{item.giveMoneySum}}&nbsp;&nbsp;&nbsp;&nbsp;{{item.giveIntegerSum==0 ? '':'兑购金'+item.giveIntegerSum+""}}</text>
  33. <view class="total_box" v-if="item.payFlag == 2 && !!item.giveIntegerSum"> <!--item.payFlag 兑购支付为2 -->
  34. <text class="text_price">合计</text>
  35. <text class="price font-42">{{item.giveIntegerSum}}</text>
  36. <text class="text_price">兑购金</text>
  37. </view>
  38. <view class="total_box" v-else-if="!!item.giveMoneySum" >
  39. <text class="text_price">合计</text>
  40. <text class="price font-42">{{item.payMoney}}</text>
  41. </view>
  42. <!-- 待付款的按钮 -->
  43. <view class="btn_box" v-if="orderList.length>0">
  44. <!-- 普通订单 -->
  45. <text class="order_name" v-if="item.name == '普通订单'">{{item.payFlag == 1? '普通订单消费金支付': '普通订单微信支付'}} </text>
  46. <text class="order_name" v-else>{{item.name}}</text>
  47. <view class="btn_order">
  48. <button v-if="status==0" class="gather cancel" @click="close(item.id,index)">取消订单</button>
  49. <button v-if="status==0" class="gather" @click="payMoney(item.id,index,item)">立即支付</button>
  50. <!-- 待发货的按钮 售后/退换的按钮 -->
  51. <button v-if="status==1 || status==3 || status==4" class="gather" @click="toDetails(item.id)">订单详情</button>
  52. <!-- 已完成的按钮 -->
  53. <button v-if="status==2" class="gather cancel" @click="toAfterSales(item.id,index)">申请售后</button>
  54. <button v-if="status==2" class="gather" @click="toConfirmOrderById(item.id,index)">确认收货</button>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="empty_box" v-if="orderList.length==0">
  59. <image :src="IMG_URL+'empty.png'" alt=""></image>
  60. <text class="text_">暂无订单记录</text>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import { IMG_URL } from '@/env.js'
  66. export default {
  67. data() {
  68. return {
  69. IMG_URL,
  70. status: null,
  71. pageNo: 1,
  72. pageSize: 10,
  73. total: null,
  74. isLock: true,
  75. nav_list: [
  76. {
  77. name: "待付款"
  78. },
  79. {
  80. name: "待发货"
  81. },
  82. {
  83. name: "待收货"
  84. },
  85. {
  86. name: "已完成"
  87. },
  88. {
  89. name: "售后/退换"
  90. }
  91. ],
  92. orderList: []
  93. }
  94. },
  95. onUnload() {
  96. uni.switchTab({
  97. url: '/pages/my/my'
  98. })
  99. },
  100. onLoad(options) {
  101. this.status = options.status
  102. console.log(this.status)
  103. this.getUserOrder(this.status);
  104. },
  105. onPullDownRefresh() {
  106. this.orderList = [];
  107. this.pageNo = 1;
  108. this.total = null;
  109. this.isLock = true;
  110. this.getUserOrder(this.status)
  111. },
  112. onReachBottom() {
  113. if(this.isLock){
  114. this.isLock = false;
  115. if(this.total !== null && this.pageNo * this.pageSize >= this.total){
  116. this.$Toast('没有更多数据了哦!');
  117. setTimeout(()=>{
  118. this.isLock = true;
  119. },3000)
  120. return
  121. }
  122. this.pageNo+=1;
  123. this.getUserOrder(this.status);
  124. }
  125. },
  126. computed: {
  127. gridData () {
  128. return this.$store.state.gridData
  129. }
  130. },
  131. methods: {
  132. // 打电话
  133. call(phone) {
  134. uni.makePhoneCall({
  135. phoneNumber: phone,
  136. success(res) {
  137. },
  138. fail(err) {
  139. }
  140. })
  141. },
  142. toGoodsInfo (item) {
  143. let idx = this.gridData.findIndex(obj => obj.id === item.bottonId)
  144. let key = idx > -1 ? this.gridData[idx].key : 'home'
  145. this.$tools.navigateTo({
  146. url: `/pagesC/goodsInfo/goodsInfo?id=${item.goodId}&type=${key}`
  147. })
  148. },
  149. // 详情
  150. toDetails(id) {
  151. uni.navigateTo({
  152. url: `./details/index?id=${id}&status=${this.status}`
  153. })
  154. },
  155. // 获取订单数据
  156. getUserOrder(type,pageSize) {
  157. uni.showLoading();
  158. const params = {
  159. pageNo: this.pageNo,
  160. pageSize: this.pageSize,
  161. type
  162. }
  163. this.$api('getOrderList',params).then(res => {
  164. let { code, result, message} = res;
  165. if(code == 200) {
  166. if(this.total == null) {
  167. this.total = result.total;
  168. }
  169. // 处理 图片
  170. result.records.forEach(item => {
  171. item.orderDetailList.forEach(item2 =>{
  172. item2.goodPic2 = item2.goodPic ==null ? '': item2.goodPic.split(',')[0]
  173. })
  174. })
  175. this.orderList = [];
  176. this.orderList = this.orderList.concat(result.records)
  177. console.log(result);
  178. }else {
  179. this.$Toast(message);
  180. }
  181. uni.hideLoading()
  182. uni.stopPullDownRefresh()
  183. this.isLock = true;
  184. }).catch(err => {
  185. uni.hideLoading()
  186. this.isLock = true;
  187. uni.stopPullDownRefresh()
  188. this.$Toast(err.message);
  189. })
  190. },
  191. // 取消订单
  192. close(id,index){
  193. const that = this
  194. uni.showModal({
  195. title: "确定取消该订单吗?",
  196. success(res) {
  197. if(res.confirm) {
  198. that.$api('deleteOrderById',{id}).then(res => {
  199. let { code, result, message} = res;
  200. if(code == 200) {
  201. that.$Toast(result);
  202. that.orderList.splice(index,1)
  203. // 删除该条数据
  204. }else {
  205. that.$Toast(message);
  206. }
  207. }).catch(err => {
  208. that.$Toast(err.message);
  209. })
  210. }else if(res.cancel){
  211. // this.$Toast('您取消了')
  212. }
  213. }
  214. })
  215. },
  216. // 立即支付
  217. payMoney(id,index,item){
  218. const that = this
  219. var type = item.payFlag
  220. if(this.orderList[index].name == '兑购订单') {
  221. this.payMoneyTeamCreateOrderPay(id,item.payFlag,item.addressId);
  222. }
  223. if(this.orderList[index].name == '拼团订单') {
  224. this.payMoneyTeamCreateOrderPay(id,item.payFlag,item.addressId);
  225. }else {
  226. const that = this
  227. // 消费金支付
  228. uni.showActionSheet({
  229. itemList: ['微信支付', '消费金支付'],
  230. success: function (res) {
  231. if (res.tapIndex + 1 == 1) {
  232. // 微信支付
  233. that.ImmediatePayment(id,type,index)
  234. }else {
  235. that.ImmediatePayment(id,1,index)
  236. }
  237. },
  238. fail: function (res) {
  239. console.log(res.errMsg);
  240. }
  241. });
  242. }
  243. },
  244. // 立即支付
  245. ImmediatePayment(id,type,index) {
  246. const that = this
  247. that.$api('submitOrderById',{id,type}).then(res => {
  248. let { code, result, message} = res;
  249. if(code == 200) {
  250. // that.$Toast(result); type = 3 为兑购
  251. if(type==3) {
  252. that.$Toast(result);
  253. that.orderList.splice(index,1);
  254. }else if(type == 1) {
  255. this.$Toast(result);
  256. that.orderList.splice(index,1);
  257. } else{
  258. uni.requestPayment({
  259. provider: 'wxpay',
  260. timeStamp: result.timeStamp,
  261. nonceStr: result.nonceStr,
  262. package: result.packageValue,
  263. signType: result.signType,
  264. paySign: result.paySign,
  265. success: res => {
  266. this.$Toast('支付成功');
  267. that.orderList.splice(index,1);
  268. },
  269. fail:error=>{
  270. this.$Toast('取消支付');
  271. this.getUserOrder(this.status);
  272. }
  273. })
  274. }
  275. // 删除该条数据
  276. }else {
  277. that.$Toast(message);
  278. }
  279. }).catch(err => {
  280. that.$Toast(err.message);
  281. })
  282. },
  283. payMoneyTeamCreateOrderPay(id,type,addressId){
  284. const that = this
  285. that.$api('teamCreateOrderPay',{id,type,addressId}).then(res => {
  286. let { code, result, message} = res;
  287. if(code == 200) {
  288. // that.$Toast(result);
  289. if(type==3) {
  290. that.$Toast(result);
  291. that.orderList.splice(index,1);
  292. }else{
  293. uni.requestPayment({
  294. provider: 'wxpay',
  295. timeStamp: result.timeStamp,
  296. nonceStr: result.nonceStr,
  297. package: result.packageValue,
  298. signType: result.signType,
  299. paySign: result.paySign,
  300. success: res => {
  301. this.$Toast('支付成功');
  302. that.orderList.splice(index,1);
  303. },
  304. fail:error=>{
  305. this.$Toast('取消支付')
  306. }
  307. })
  308. }
  309. }
  310. }).catch(err => {
  311. that.$Toast(err.message);
  312. })
  313. },
  314. // 确认收货
  315. toConfirmOrderById(id,index){
  316. const that = this
  317. uni.showModal({
  318. title: "确定该商品收货吗?",
  319. success(res) {
  320. if(res.confirm) {
  321. that.$api('confirmOrderById',{id}).then(res => {
  322. let { code, result, message} = res;
  323. if(code == 200) {
  324. that.$Toast(result);
  325. that.orderList.splice(index,1);
  326. // 删除该条数据
  327. }else {
  328. that.$Toast(message);
  329. }
  330. }).catch(err => {
  331. that.$Toast(err.message);
  332. })
  333. }else if(res.cancel){
  334. // this.$Toast('您取消了')
  335. }
  336. }
  337. })
  338. },
  339. // 申请售后
  340. toAfterSales(id,index){
  341. const that = this
  342. this.$tools.navigateTo({
  343. url: '/pagesA/my_other_list/after_sale_order/after_sale_order?id='+id
  344. });
  345. },
  346. getInfo(e) {
  347. this.status = e;
  348. this.orderList = [];
  349. this.pageNo = 1;
  350. this.total = null;
  351. this.isLock = true;
  352. this.getUserOrder(this.status)
  353. console.log("获取新数据",e)
  354. }
  355. }
  356. }
  357. </script>
  358. <style lang="scss" scoped>
  359. .empty_box{
  360. width: 100%;
  361. height: 80vh;
  362. display: flex;
  363. flex-direction: column;
  364. justify-content: center;
  365. align-items: center;
  366. image{
  367. width: 371rpx;
  368. height: 371rpx;
  369. }
  370. .text_{
  371. margin-top: 10rpx;
  372. font-size: 36rpx;
  373. font-weight: bold;
  374. color: #01AEEA;
  375. }
  376. }
  377. .item {
  378. width: 711rpx;
  379. margin: 0 auto;
  380. margin-top: 10rpx;
  381. border-radius: 24rpx;
  382. padding-bottom: 21rpx;
  383. box-shadow: 0 3rpx 6rpx 0 rgba(0, 0, 0, 0.16);
  384. .time{
  385. width: 648rpx;
  386. margin: 0 auto;
  387. margin-top: 30rpx;
  388. padding-top: 34rpx;
  389. padding-bottom: 15rpx;
  390. border-bottom: 1px solid rgba(112,112,112,0.2);
  391. display: flex;
  392. justify-content: space-between;
  393. font-size: 36rpx;
  394. .time_text {
  395. color: #333;
  396. }
  397. .phone{
  398. color: #333333;
  399. }
  400. }
  401. .goods_item{
  402. display: flex;
  403. width: 648rpx;
  404. margin: 0 auto;
  405. margin-top: 22rpx;
  406. padding-bottom: 26rpx;
  407. border-bottom: 1px solid rgba(112,112,112,0.2);
  408. &:last-child{
  409. border-bottom: none;
  410. }
  411. image{
  412. width: 200rpx;
  413. height: 200rpx;
  414. border-radius: 20rpx;
  415. }
  416. .right_box{
  417. display: flex;
  418. flex-direction: column;
  419. font-size: 36rpx;
  420. margin-left: 25rpx;
  421. .title{
  422. color: #000;
  423. width: 440rpx;
  424. font-size: 36rpx;
  425. line-height: 39rpx;
  426. }
  427. .center_box{
  428. display: flex;
  429. justify-content: space-between;
  430. align-items: center;
  431. color: #01AEEA;
  432. font-size: 36rpx;
  433. .money_box{
  434. .red{
  435. color: #DB0618;
  436. }
  437. .min{
  438. font-size: 20rpx;
  439. }
  440. .bigs{
  441. font-size: 36rpx;
  442. }
  443. }
  444. .back_money{
  445. color: #fff;
  446. background-color: #FFA952;
  447. border-radius: 15rpx;
  448. height: 47rpx;
  449. line-height: 47rpx;
  450. box-sizing: border-box;
  451. font-size: 36rpx;
  452. padding-left: 15rpx;
  453. padding-right: 15rpx;
  454. }
  455. .back_iconx{
  456. font-size: 38rpx;
  457. }
  458. }
  459. }
  460. }
  461. .sum_back_momey{
  462. height: 47rpx;
  463. line-height: 47rpx;
  464. border-radius: 10rpx;
  465. padding: 6rpx 14rpx;
  466. margin-right: 45rpx;
  467. color: #fff;
  468. background-color: #FFA952;
  469. font-size: 36rpx;
  470. }
  471. .total_box{
  472. display: flex;
  473. width: 648rpx;
  474. margin: 0 auto;
  475. justify-content: flex-end;
  476. font-size: 36rpx;
  477. margin-top: 6rpx;
  478. padding-bottom: 16rpx;
  479. border-bottom: 1px solid rgba(112,112,112,0.2);
  480. .text_price{
  481. font-size: 34rpx;
  482. }
  483. .price{
  484. font-size: 36rpx;
  485. color: #DB0618;
  486. }
  487. text{
  488. &:last-child{
  489. }
  490. }
  491. }
  492. .btn_box{
  493. display: flex;
  494. justify-content: space-between;
  495. align-items: center;
  496. .order_name{
  497. margin-left: 30rpx;
  498. margin-top: 20rpx;
  499. font-size: 36rpx;
  500. width: 30%;
  501. }
  502. .btn_order{
  503. width: 70%;
  504. display: flex;
  505. height: 100%;
  506. }
  507. .gather{
  508. height: 60rpx;
  509. margin-top: 23rpx;
  510. margin-left: 0;
  511. margin-right: 21rpx;
  512. border: 1rpx solid #01AEEA;
  513. color: #01AEEA;
  514. font-size: 32rpx;
  515. border-radius: 30rpx;
  516. line-height: 60rpx;
  517. }
  518. .cancel{
  519. border: 1rpx solid #6C6C6C;
  520. font-size: 36rpx;
  521. color: #6C6C6C;
  522. }
  523. }
  524. }
  525. </style>