index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view>
  3. <!-- <view class="coupon_status_list">
  4. <view class="coupon_status_item" :class="requestParam.status==0?'active':''" @click="setStatus(0)"> 全部 </view>
  5. <view class="coupon_status_item" :class="requestParam.status==1?'active':''" @click="setStatus(1)"> 待发货 </view>
  6. <view class="coupon_status_item" :class="requestParam.status==2?'active':''" @click="setStatus(2)"> 已发货 </view>
  7. </view> -->
  8. <view class="to_bottom" v-if="!couponList.length"> -----还没有优惠券啦-----</view>
  9. <view class="coupon_list">
  10. <view class="coupon_item" v-for="(item,index) in couponList" :key="index" @click="toUse(item)">
  11. <view class="box_left">
  12. <view class="rebate" v-if="item.rebate_type == 1" > ¥{{item.rebate}}</view>
  13. <view class="rebate" v-if="item.rebate_type == 2" > 打 {{item.rebate}} 折</view>
  14. <view class="rebate" v-if="item.rebate_type == 3" > 赠 <text v-if="item.rebate_scope.length">
  15. {{item.rebate_scope[0].product_name}}
  16. </text> </view>
  17. <view class="std_pay"> 满{{item.std_pay}}</view>
  18. </view>
  19. <view class="box_right">
  20. <view class="coupon_title">
  21. <view class="coupon_name" v-if="item.rebate_type == 1">满减券</view>
  22. <view class="coupon_name" v-if="item.rebate_type == 2">折扣券</view>
  23. <view class="coupon_name" v-if="item.rebate_type == 3">赠品券</view>
  24. <view class="coupon_status" v-if="item.status == 0">未使用</view>
  25. <view class="coupon_status" v-if="item.status == 1">已使用</view>
  26. <view class="coupon_status" v-if="item.status == 2">已暂停</view>
  27. <view class="coupon_status" v-if="item.status == 3">已过期</view>
  28. <view class="coupon_status" v-if="item.status == 4">已作废</view>
  29. </view>
  30. <view class="coupon_box">
  31. <view class="product_scope">
  32. <text class="" v-if="item.type_id == 1">限定商品可用</text>
  33. <text class="" v-if="item.type_id == 2">全场可用</text>
  34. </view>
  35. <view class="coupon_info">
  36. <view class="coupon_exp">{{item.exp_time}} 到期</view>
  37. </view>
  38. </view>
  39. <view class="to_use" v-if="item.status == 0">
  40. <view class="use_btn" >去使用</view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="to_bottom" v-if="isLast"> -----到底啦-----</view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. // 产品列表
  53. couponList:[],
  54. // 请求参数
  55. requestParam:{
  56. page:1,
  57. status:0,
  58. },
  59. // 是否最后一页
  60. isLast:false,
  61. // 是否请求中
  62. isReqing:false,
  63. };
  64. },
  65. onLoad() {
  66. // 登录提示
  67. if( !this.$checkAccess.alterLogin() ) return ;
  68. // 初始化页码为1
  69. this.requestParam.page = 1;
  70. // 是否是最后一页
  71. this.isLast = false;
  72. // 设置请求中
  73. this.isReqing = true;
  74. // 请求列表
  75. this.$http.request('api/custom_coupon/get_list',this.requestParam).then((re)=>{
  76. // 设置非请求中
  77. this.isReqing = false;
  78. // 成功结果
  79. if( re.code == 'success' ){
  80. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  81. this.couponList = re.data.data;
  82. }
  83. });
  84. },
  85. onShow() {
  86. // 登录提示
  87. if( !this.$checkAccess.alterLogin() ) return ;
  88. // 没有数据的话,或者请求中,不允许刷新
  89. if( this.couponList.length > 0 || this.isReqing ) return ;
  90. // 设置请求中
  91. this.isReqing = true;
  92. // 请求列表
  93. this.$http.request('api/custom_coupon/get_list',this.requestParam).then((re)=>{
  94. // 设置非请求中
  95. this.isReqing = false;
  96. // 成功结果
  97. if( re.code == 'success' ){
  98. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  99. this.couponList = re.data.data;
  100. }
  101. });
  102. },
  103. onPullDownRefresh() {
  104. // 登录提示
  105. if( !this.$checkAccess.alterLogin() ) return ;
  106. // 如果请求中,不允许请求,
  107. if( this.isReqing ) return false;
  108. // 初始化页码为1
  109. this.requestParam.page = 1;
  110. // 是否是最后一页
  111. this.isLast = false;
  112. // 设置请求中
  113. this.isReqing = true;
  114. // 请求列表
  115. this.$http.request('api/custom_coupon/get_list',this.requestParam).then((re)=>{
  116. // 设置非请求中
  117. this.isReqing = false;
  118. // 成功结果
  119. if( re.code == 'success' ){
  120. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  121. this.couponList = re.data.data;
  122. }
  123. });
  124. uni.stopPullDownRefresh();
  125. },
  126. onReachBottom() {
  127. // 登录提示
  128. if( !this.$checkAccess.alterLogin() ) return ;
  129. // 如果页码是0,避免第一页重复
  130. if( this.requestParam.page < 1 ) return;
  131. // 最后一页不请求
  132. if( this.isLast ) return;
  133. // 设置请求中
  134. this.isReqing = true;
  135. // 增加一页
  136. this.requestParam.page = this.requestParam.page+1;
  137. // 请求列表
  138. this.$http.request('api/custom_coupon/get_list',this.requestParam).then((re)=>{
  139. // 设置非请求中
  140. this.isReqing = false;
  141. // 成功结果
  142. if( re.code == 'success' ){
  143. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  144. // 追加数据
  145. this.couponList.push(...re.data.data);
  146. }
  147. });
  148. },
  149. methods:{
  150. toUse(item){
  151. // 没有范围
  152. if( item.type_id == 2 ){
  153. uni.switchTab({url:"/pages/index/index"});
  154. return;
  155. }
  156. // 只有一个商品,直接跳转到对应商品
  157. if( item.product_scope.length == 1 ){
  158. uni.navigateTo({
  159. url:"/pages/product/index?product_id="+item.product_scope[0]
  160. })
  161. return;
  162. }
  163. // 没有范围
  164. if( item.product_scope.length > 1 ){
  165. uni.navigateTo({
  166. url:"/pages/coupon/product?coupon_id="+item.coupon_id
  167. });
  168. return;
  169. }
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="less">
  175. .coupon_status_list{
  176. display: block;
  177. height: 60rpx;
  178. color: #666666;
  179. line-height: 60rpx;
  180. background: #FFFFFF;
  181. padding: 10rpx 35rpx;
  182. .coupon_status_item{
  183. float: left;
  184. font-size: 28rpx;
  185. padding: 0rpx 20rpx;
  186. }
  187. .coupon_status_item.active{
  188. color: #000000;
  189. font-weight: bold;
  190. }
  191. }
  192. .coupon_list{
  193. display: block;
  194. overflow: hidden;
  195. margin: 10rpx auto;
  196. .coupon_item{
  197. height: 200rpx;
  198. display: block;
  199. background: #FFFFFF;
  200. margin: 10rpx auto;
  201. .box_left{
  202. float: left;
  203. width: 160rpx;
  204. height: 160rpx;
  205. font-size: 20rpx;
  206. text-align: center;
  207. margin-left: 35rpx;
  208. line-height: 60rpx;
  209. margin-top: 20rpx;
  210. background: pink;
  211. .rebate{
  212. width: 120rpx;
  213. height: 60rpx;
  214. margin: 0rpx auto;
  215. line-height: 60rpx;
  216. margin-top: 20rpx;
  217. overflow: hidden;
  218. white-space: nowrap;
  219. text-overflow: ellipsis;
  220. }
  221. }
  222. .box_right{
  223. float: left;
  224. width: 485rpx;
  225. margin-left: 35rpx;
  226. padding-top: 20rpx;
  227. overflow: hidden;
  228. .coupon_title{
  229. width: 485rpx;
  230. max-height: 80rpx;
  231. font-size: 30rpx;
  232. overflow: hidden;
  233. line-height: 40rpx;
  234. padding: 0rpx 0rpx;
  235. .coupon_name{
  236. float: left;
  237. height: 40rpx;
  238. width: 380rpx;
  239. }
  240. .coupon_status{
  241. width: 100rpx;
  242. float: right;
  243. color: #999999;
  244. font-size: 24rpx;
  245. text-align: center;
  246. }
  247. }
  248. .coupon_box{
  249. float: left;
  250. width: 365rpx;
  251. overflow: hidden;
  252. .product_scope{
  253. width: 365rpx;
  254. height: 80rpx;
  255. color: #999999;
  256. font-size: 24rpx;
  257. overflow: hidden;
  258. line-height: 80rpx;
  259. }
  260. .coupon_info{
  261. width: 365rpx;
  262. max-height: 80rpx;
  263. font-size: 30rpx;
  264. overflow: hidden;
  265. line-height: 40rpx;
  266. padding: 0rpx 0rpx;
  267. .coupon_exp{
  268. float: left;
  269. font-size: 20rpx;
  270. }
  271. }
  272. }
  273. .to_use{
  274. float: right;
  275. width: 100rpx;
  276. margin-top: 75rpx;
  277. overflow: hidden;
  278. .use_btn{
  279. color: #FFFFFF;
  280. width: 100rpx;
  281. height: 40rpx;
  282. font-size: 24rpx;
  283. line-height: 40rpx;
  284. text-align: center;
  285. border-radius: 20rpx;
  286. background-color: #F59A23;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. </style>