index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="content">
  3. <view class="empty-data" v-if="coupon.length == 0">
  4. <u-empty mode="order" icon="/static/image/order_none.png" text="暂无抖音团购订单"></u-empty>
  5. </view>
  6. <view class="coupon-list" v-else>
  7. <view class="coupon-item" v-for="(item,indx) in coupon" :key="indx">
  8. <view class="header">{{item.certificate_id}}</view>
  9. <view class="body">
  10. <view class="info">
  11. <view class="name">{{item.product_name}}</view>
  12. <view class="desc">x {{item.count}}张</view>
  13. <view class="desc">有效期至{{item.expire_at}}</view>
  14. </view>
  15. <view class="right">
  16. <button class="btn" type="primary" @click="toDetail(item.certificate_id)" v-if="item.status==1">去使用</button>
  17. </view>
  18. </view>
  19. <!-- <view class="footer">
  20. <view class="state"></view>
  21. <button class="btn" type="primary" @click="toDetail(item.order_id)">立即使用</button>
  22. </view> -->
  23. <view class="state-img" v-if="item.status==1"><image src="/static/image/order-dot.png" mode="widthFix"></image></view>
  24. <view class="state-img" v-if="item.status==4"><image src="/static/image/ex.png" mode="widthFix"></image></view>
  25. </view>
  26. <navigator hover-class="none" url="/pages/user/license" class="tips">小程序资质亮照</navigator>
  27. </view>
  28. <!-- <view class="kf-service" @click="getData"><image src="/static/image/refrsh.png"></image></view> -->
  29. </view>
  30. </template>
  31. <script>
  32. var app;
  33. import * as Api from "@/static/api/home.js";
  34. export default {
  35. data() {
  36. return {
  37. user:{},
  38. coupon:[],
  39. account:"",
  40. option:{}
  41. }
  42. },
  43. onShow() {
  44. this.getData()
  45. },
  46. onLoad(option) {
  47. app = this;
  48. app.option = option;
  49. // app.getData()
  50. },
  51. onShareAppMessage(res) {
  52. if (res.from === 'button') {// 来自页面内分享按钮
  53. console.log(res.target)
  54. }
  55. return {
  56. title: "团购自助兑换",
  57. path: '/pages/index/index'
  58. }
  59. },
  60. methods: {
  61. toService(){
  62. },
  63. toDetail(order){
  64. Api.orderDetail({"order":order}).then((res)=>{
  65. if (res.code ==0) {
  66. return app.$dialog.showSuccess(res.msg)
  67. }
  68. if (res.data.status > 1) {
  69. return app.$dialog.showSuccess("该订单已完成预约","none",function(){
  70. app.getData()
  71. })
  72. }
  73. uni.navigateTo({
  74. url:"/pages/order/store?type=1&order="+order
  75. })
  76. })
  77. },
  78. getData(){
  79. uni.login({
  80. success(lres){
  81. app.option.auth = lres.code
  82. Api.data(app.option).then((res)=>{
  83. uni.hideLoading();
  84. if (res.code == 0) {
  85. return app.$dialog.showSuccess(res.msg);
  86. }
  87. uni.setStorageSync("user_data", res.data.user)
  88. uni.setStorageSync("user_token", res.data.user.access_token)
  89. app.userInfo = res.data.user;
  90. app.coupon = res.data.coupon;
  91. })
  92. },fail(res){
  93. app.$dialog.showSuccess("登录失败,请重启小程序")
  94. }
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style>
  101. page{
  102. background-color: #f8f8f8;
  103. }
  104. .kf-service{
  105. position: fixed;
  106. right: 20upx;
  107. bottom: 20%;
  108. width: 80upx;
  109. height: 80upx;
  110. display: flex;
  111. align-items: center;
  112. justify-content: center;
  113. }
  114. .kf-service image{
  115. width: 60upx;
  116. height: 60upx;
  117. vertical-align: middle;
  118. }
  119. .empty-data{
  120. height: 100vh;
  121. display: flex;
  122. align-items: center;
  123. justify-content: center;
  124. }
  125. .tips{text-align: center;line-height: 80upx;color: #666;font-size: 28upx;}
  126. .coupon-item{background-color: #fff;border-radius: 10upx;width: calc(95% - 40upx);margin: 20upx auto;border: 2upx solid #fff;border-radius: 10upx;position: relative;}
  127. .coupon-item .state-img{position: absolute;right: 0;top: 0;}
  128. .coupon-item .state-img image{width: 100upx;height: 100upx;}
  129. .coupon-item .header{padding: 20upx;font-size: 28upx;color: #333;line-height: 48upx;border-bottom: 2upx solid #f8f8f8;}
  130. .coupon-item .footer{padding: 20upx;border-top: 2upx solid #f8f8f8;display: flex;justify-content: space-between;}
  131. .coupon-item .footer .state{flex: 1;}
  132. .coupon-item .footer .btn{width: 50%;font-size: 28upx;}
  133. .coupon-item .body{display: flex;align-items: center;margin: 20upx 0;justify-content: space-between;}
  134. .coupon-item .img image{width: 160upx;height: 160upx;}
  135. .coupon-item .info{padding: 0 20upx;}
  136. .coupon-item .btn{font-size: 28upx;margin-right: 20upx;}
  137. .coupon-item .name{font-size: 32upx;color: #333;line-height: 46upx;}
  138. .coupon-item .desc{color: #666;font-size: 28upx;line-height: 48upx;}
  139. </style>