coupons.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view>
  3. <!--mine/coupons/coupons.wxml-->
  4. <view class="tab bgfff dflex">
  5. <view :class="'li ' + (currentTab == 0 ? 'active' : '')" data-current="0" @tap="tab">未使用</view>
  6. <view :class="'li ' + (currentTab == 1 ? 'active' : '')" data-current="1" @tap="tab">已使用</view>
  7. <view :class="'li ' + (currentTab == 2 ? 'active' : '')" data-current="2" @tap="tab">已失效</view>
  8. </view>
  9. <navigator url="/product/coupon/coupon" hover-class="none" class="ling ddflex">
  10. <image src="../static/mine/images/quan.png" class="quan-img"></image>
  11. <view class="fflex">去领券中心</view>
  12. <image src="../../static/pages/images/rico.png" class="rico"></image>
  13. </navigator>
  14. <block v-if="pageList.length > 0">
  15. <view class="list">
  16. <view :class="'li' + (item.couponType === 3 ? ' tong' : '') + (currentTab == 0 ? '' : ' hui')" v-for="(item, index) in pageList" :key="index">
  17. <view class="info dflex">
  18. <image :src="item.couponIcon" mode="aspectFill" class="info-img" v-if="item.couponIcon"></image>
  19. <view class="flex">
  20. <view class="title">{{item.couponType === 3 ? '通用券' : item.couponType === 1 ? '满减券' : item.couponType === 4 ? '免除券':'代金券'}}-{{item.couponTitle}}</view>
  21. <view class="time">有效期至{{item.couponEnd}}</view>
  22. </view>
  23. <view class="info-r" v-if="item.couponType != 4">
  24. <view class="money"><text>¥</text>{{item.couponAmount}}</view>
  25. <view class="man">{{item.couponBrief}}</view>
  26. </view>
  27. </view>
  28. <view class="li-bot dflex">
  29. <view class="check dflex flex" @click="checks(item,index)">查看详情
  30. <!-- <view class="xian">限青岛大虾</view> -->
  31. <image src="../static/mine/images/bico1.png" v-if="item.couponType === 3"></image>
  32. <image src="../static/mine/images/bico.png" v-else></image>
  33. </view>
  34. <image :src="'../static/mine/images/' + (item.couponType === 3 ? 'ma_white' : 'ma_dark') + '.png'" class="ma"></image>
  35. <view class="yong dflex" @tap="toIndex(item)" v-if="currentTab == 0">去使用</view>
  36. <view class="yi" v-else>
  37. <image src="../static/mine/images/yishiyong.png" class="yipic" v-if="currentTab == 1"></image>
  38. <image src="../static/mine/images/yishixiao.png" class="yipic" v-else></image>
  39. </view>
  40. </view>
  41. <view class="infos" v-if="item.isShow">
  42. <view>1.使用时间:{{item.couponStart}}至{{item.couponEnd}}</view>
  43. <view v-if="item.couponBrief">2.使用范围:{{item.couponBrief}}</view>
  44. <view v-if="item.useActionsList && item.useActionsList.length > 0" class="i-pro">{{item.couponBrief?'3':'2'}}.指定产品:
  45. <text v-for="(it,idx) in item.useActionsList" :key="idx" @click="toDetail(it)">{{it.name}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- <view :class="'list ' + (currentTab == 0 ? 'show' : 'hide')">
  51. <view v-for="(item, index) in pageList" :key="index" class="li" @tap="toIndex">
  52. <view class="lit">
  53. <image :src="picUrlss+'yhq_wei.png'" class="lqbg" v-if="item.couponState==1"></image>
  54. <image :src="picUrlss+'yiguoqi.png'" class="lqbg"
  55. v-if="item.couponState==2||item.couponState==3"></image>
  56. <view class="lits dflex">
  57. <view class="left"><text>¥</text><text class="jine">{{item.couponAmount}}</text>元</view>
  58. <view class="tong flex">
  59. <view>{{item.couponType === 1 ? '满减券' : '代金券'}}</view>
  60. <text>{{item.couponBrief}}</text>
  61. </view>
  62. <view class="lqbtn" v-if="item.couponState==1">立即使用</view>
  63. <view class="lqbtn" v-if="item.couponState==2">已使用</view>
  64. <view class="lqbtn" v-if="item.couponState==3">已过期</view>
  65. </view>
  66. </view>
  67. <view class="dflex bot">
  68. <view class="right">
  69. <view>使用日期:{{item.couponStart}}至{{item.couponEnd}}</view>
  70. <view>适用范围:{{item.couponTitle}}</view>
  71. </view>
  72. <image src="/static/pages/images/erweima.png" class="erweima" v-if="item.couponState==1">
  73. </image>
  74. <image src="/static/pages/images/yhq-ygq.png" class="erweima"
  75. v-if="item.couponState==2||item.couponState==3"></image>
  76. </view>
  77. </view>
  78. </view>
  79. <view :class="'list ' + (currentTab == 1 ? 'show' : 'hide')">
  80. <view v-for="(item, index) in pageList" :key="index" class="li fail">
  81. <view class="lit">
  82. <image :src="picUrlss+'yhq_yi.png'" class="lqbg"></image>
  83. <view class="lits dflex">
  84. <view class="left"><text>¥</text><text class="jine">{{item.couponAmount}}</text>元</view>
  85. <view class="tong flex">
  86. <view>{{item.couponType === 1 ? '满减券' : '代金券'}}</view>
  87. <text>{{item.couponBrief}}</text>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="right">
  92. <view>使用日期:{{item.couponStart}}至{{item.couponEnd}}</view>
  93. <view>适用范围:{{item.couponTitle}}</view>
  94. </view>
  95. <image src="/static/pages/images/guoqi.png" class="guoqi"></image>
  96. </view>
  97. </view> -->
  98. </block>
  99. <view class="nodata" v-if="ishow">
  100. <image :src="picUrlss+'empty_yhq.png'"></image>
  101. <text>暂无优惠券</text>
  102. </view>
  103. </view>
  104. </template>
  105. <script>
  106. // mine/coupons/coupons.js
  107. const req = require("../../utils/request.js");
  108. const app = getApp();
  109. export default {
  110. data() {
  111. return {
  112. picUrlss: req.public.picUrls,
  113. currentTab: 0,
  114. form: {
  115. page: 1,
  116. limit: 10,
  117. couponState: 1
  118. },
  119. pageList: [],
  120. isLoad: true,
  121. ishow: false
  122. };
  123. },
  124. components: {},
  125. props: {},
  126. onShow: function() {
  127. this.form.page = 1;
  128. this.isLoad = true;
  129. this.setData({
  130. pageList: []
  131. });
  132. this.loadCoupon();
  133. },
  134. onReachBottom() {
  135. this.form.page++;
  136. this.loadCoupon();
  137. },
  138. methods: {
  139. tab(e) {
  140. let that = this;
  141. const index = e.currentTarget.dataset.current;
  142. if (that.currentTab === index) {
  143. return false;
  144. }
  145. that.setData({
  146. currentTab: index
  147. });
  148. console.log('currentTab==' + that.currentTab)
  149. that.form.couponState = index == 0 ? 1 : index == 1 ? 2 : 3;
  150. // console.log(index, that.form.couponState);
  151. that.form.page = 1;
  152. that.isLoad = true;
  153. that.setData({
  154. pageList: []
  155. });
  156. that.loadCoupon();
  157. },
  158. loadCoupon() {
  159. let isShowLoading = false;
  160. if (this.form.page == 1 && !isShowLoading) {
  161. req.loadIng('加载中');
  162. isShowLoading = true;
  163. }
  164. if (!this.isLoad) return false;
  165. this.isLoad = false;
  166. let that = this;
  167. req.getRequest('/api/coupon/user', this.form, data => {
  168. if (data && data.length == 10) this.isLoad = true;
  169. if (that.form.page > 1) data = that.pageList.concat(data);
  170. data.map(it=>{
  171. it.isShow = false;
  172. return it;
  173. })
  174. that.setData({
  175. pageList: data
  176. });
  177. if (!this.pageList || data.length <= 0) {
  178. that.setData({
  179. ishow: true
  180. });
  181. } else {
  182. that.setData({
  183. ishow: false
  184. });
  185. }
  186. if (isShowLoading) {
  187. uni.hideLoading();
  188. isShowLoading = false;
  189. }
  190. });
  191. },
  192. toIndex(item) {
  193. let arr = item.useActionList;
  194. let special = ''
  195. arr.map(it=>{
  196. if(it.indexOf('APPOINT_SPECIAL')>-1){
  197. special = it;
  198. }
  199. })
  200. if(special) {
  201. special = JSON.parse(special.split(':')[1]);
  202. app.globalData.navigateTo('pages/topic/topic?id='+special[0]);
  203. }else{
  204. // header.appId=='ZQ1VK5oc17I387E'?'/pages/timelyDelivery/index':'/pages/index/index'
  205. if (req.header.appId == 'ZQ1VK5oc17I387E') {
  206. app.globalData.switchTab('pages/timelyDelivery/index')
  207. } else {
  208. app.globalData.switchTab('pages/index/index')
  209. }
  210. }
  211. },
  212. checks(item,index){
  213. let pageList = this.pageList;
  214. if(pageList[index].isShow){
  215. pageList[index].isShow = false;
  216. }else{
  217. pageList.map(it=>{
  218. it.isShow = false;
  219. return it;
  220. });
  221. pageList[index].isShow = true;
  222. }
  223. },
  224. toDetail(it){
  225. uni.navigateTo({
  226. url: '/product/detail/detail?id=' + it.id + '&merchantId=' + req.getStorage('MERCHANT').id
  227. })
  228. }
  229. }
  230. };
  231. </script>
  232. <style>
  233. @import "./coupons.css";
  234. </style>