discountCard.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view class="box">
  3. <!-- <view class="tab">
  4. <view class="tabLine" :class="{tabActive:tabIndex==1}" @click="tabClick(1)">可使用</view>
  5. <view class="tabLine" :class="{tabActive:tabIndex==2}" @click="tabClick(2)">可赠送</view>
  6. </view> -->
  7. <view class="main" :class="{mainActive:tabIndex==1}">
  8. <view class="okBox" v-if="tabIndex==1">
  9. <view class="tabLine2" :class="{tabActive2:tabIndex2==0}" @click="tabClick2(0)">可使用</view>
  10. <view class="tabLine2" :class="{tabActive2:tabIndex2==2}" @click="tabClick2(2)">已使用</view>
  11. <view class="tabLine2" :class="{tabActive2:tabIndex2==1}" @click="tabClick2(1)">已过期</view>
  12. </view>
  13. <view style="height: 92rpx;"></view>
  14. <view class="itemBg" v-for="(item,index) in currentList" @click="goDetail(item.id)">
  15. <view class="itemTop">
  16. <view class="leftB">
  17. <view class="use" v-if="item.state==0">¥<span class="use2">{{item.actMoney}}</span></view>
  18. <view class="used" v-else>¥<span class="used2">{{item.actMoney}}</span></view>
  19. <view class="tiaojian">{{item.whereMoney!==0?'满'+item.whereMoney+'元可用':'满任意金额可用'}}</view>
  20. </view>
  21. <view class="centerB">
  22. <view class="name" >
  23. <span class="djq">代金券</span>
  24. <span>{{item.actName}}</span>
  25. </view>
  26. <view class="plateNumer" v-if="item.plateNumer">限鲁{{item.plateNumer}}使用</view>
  27. <view class="time" v-if="item.startTime">有效期:{{item.startTime.slice(0,10)}}-{{item.endTime.slice(0,10)}}</view>
  28. <view class="time" v-else>有效期:领取后{{item.endOffsetDays}}天</view>
  29. </view>
  30. <view class="rightB">
  31. <image src="../../static/img/icon_yishiyong.png" mode="" v-if="item.state==2&&tabIndex==1" class="couponlineTopImg"></image>
  32. <image src="../../static/img/icon_guoqi.png" mode="" v-if="item.state==1&&tabIndex==1" class="couponlineTopImg"></image>
  33. <!-- <view class="shareB" v-if="item.shareQty>0&&tabIndex==2" @click.stop="">
  34. <image src="../../static/img/icon_share.png" alt="" class="couponlineshareImg"></image>
  35. <view class="keshare">赠送给好友</view>
  36. </view> -->
  37. </view>
  38. </view>
  39. <view class="itemBottom" @click.stop="">
  40. <view class="rightJian">使用规则
  41. <image src="../../static/img/little_rightArrow.png" mode="" style="width: 24rpx;height: 24rpx;"></image>
  42. </view>
  43. <view class="gouse" v-if="item.usedState==0">去使用</view>
  44. </view>
  45. <!-- <view class="itemBottom">
  46. <view></view>
  47. <view @click="goDetail(item.id)" class="rightJian">查看详情
  48. <image src="../../static/img/little_rightArrow.png" mode="" style="width: 24rpx;height: 24rpx;"></image>
  49. </view>
  50. </view> -->
  51. </view>
  52. <!-- 无数据空白页 -->
  53. <nodata v-if="items.length==0"></nodata>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import nodata from '@/components/nodata/nodata.vue'
  59. export default {
  60. components: {
  61. nodata
  62. },
  63. computed: {
  64. currentList () {
  65. if (this.tabIndex == 2) {
  66. return this.items.filter(item => ~~item.shareQty > 0)
  67. } else {
  68. return this.items.filter(item => item.state == this.tabIndex2)
  69. }
  70. }
  71. },
  72. data() {
  73. return {
  74. tabIndex: 1,
  75. tabIndex2: 0,
  76. items: [],
  77. }
  78. },
  79. onLoad(opt) {
  80. this.tabIndex = opt.num;
  81. this.myOrderCoupon()
  82. },
  83. onShow() {
  84. console.log(this.tabIndex)
  85. this.myOrderCoupon()
  86. },
  87. methods: {
  88. goDetail(id) {
  89. uni.navigateTo({
  90. url: 'discountCardDetail?id=' + id
  91. })
  92. },
  93. tabClick(num) {
  94. this.tabIndex = num;
  95. },
  96. tabClick2(num) {
  97. this.tabIndex2 = num;
  98. },
  99. myOrderCoupon() {
  100. uni.showLoading({
  101. title: '加载中'
  102. })
  103. this.$http('opencoupon/listCoupon', {
  104. // page: this.page,
  105. // limit: 10,
  106. }, 'POST').then(res => {
  107. uni.hideLoading();
  108. // var list = res.data.Items
  109. var list = res.data
  110. // 处理 undefined和null转为空白字符串
  111. // list.forEach((item, index) => {
  112. // for (const key in item) {
  113. // item[key] = this.$praseStrEmpty(item[key])
  114. // }
  115. // })
  116. this.items = list
  117. })
  118. },
  119. }
  120. }
  121. </script>
  122. <style scoped>
  123. .box {
  124. min-height: 100vh;
  125. background: #F4F5F7;
  126. }
  127. .djq{
  128. background: linear-gradient(128deg, #FFE4C5 0%, #FDC692 100%);
  129. border-radius: 4rpx;
  130. height: 34rpx;
  131. width: 76rpx;
  132. line-height: 34rpx;
  133. text-align: center;
  134. color: #2B2219;
  135. font-size: 20rpx;
  136. margin-top: 4rpx;
  137. margin-right: 10rpx;
  138. }
  139. .plateNumer{
  140. color: #FF0000;
  141. line-height: 30rpx;
  142. font-size: 22rpx;
  143. padding: 3rpx 0rpx;
  144. width: 193rpx;
  145. text-align: center;
  146. background: rgba(255,0,0,0.06);
  147. border-radius: 4rpx;
  148. margin-top: 10rpx;
  149. }
  150. .gouse{
  151. width: 99rpx;
  152. height: 44rpx;
  153. border-radius: 22rpx;
  154. border: 1rpx solid #FF0000;
  155. text-align: center;
  156. line-height: 42rpx;
  157. }
  158. .tab {
  159. background: #FFFFFF;
  160. display: flex;
  161. justify-content: space-around;
  162. line-height: 92rpx;
  163. position: fixed;
  164. width: calc(100vw - 48rpx);
  165. padding-left: 24rpx;
  166. padding-right: 24rpx;
  167. height: 92rpx;
  168. z-index: 11;
  169. }
  170. .tabLine {
  171. font-size: 30rpx;
  172. text-align: center;
  173. }
  174. .tabActive {
  175. color: #FF0000;
  176. border-bottom: 4rpx solid #FF0000;
  177. }
  178. .main {
  179. /* padding-top: 92rpx; */
  180. padding-bottom: 20rpx;
  181. background-color: #F4F5F7;
  182. }
  183. .mainActive{
  184. /* padding-top: 184rpx; */
  185. padding-bottom: 20rpx;
  186. background-color: #F4F5F7;
  187. }
  188. .okBox {
  189. background: #FFFFFF;
  190. display: flex;
  191. justify-content: flex-start;
  192. align-items: center;
  193. /* border-top: 1rpx solid #EEEEEE; */
  194. position: fixed;
  195. width: 100vw;
  196. padding-left: 24rpx;
  197. padding-right: 24rpx;
  198. /* margin-top: -93rpx; */
  199. height: 92rpx;
  200. z-index: 11;
  201. }
  202. .tabLine2 {
  203. font-size: 28rpx;
  204. text-align: center;
  205. width: 144rpx;
  206. height: 56rpx;
  207. background: #F4F5F7;
  208. border-radius: 28rpx;
  209. line-height: 56rpx;
  210. margin-right: 24rpx;
  211. }
  212. .tabActive2 {
  213. background-color: rgba(240, 59, 59, 0.06);
  214. border-radius: 28rpx;
  215. background-color: 0.06;
  216. font-size: 28rpx;
  217. color: #FF0000;
  218. width: 144rpx;
  219. height: 56rpx;
  220. line-height: 56rpx;
  221. margin-right: 24rpx;
  222. }
  223. .itemBg {
  224. margin: 20rpx 24rpx 0rpx;
  225. background-color: #FFFFFF;
  226. border-radius: 10rpx;
  227. padding: 40rpx 20rpx 20rpx;
  228. }
  229. .itemTop {
  230. display: flex;
  231. justify-content: space-between;
  232. margin-bottom: 40rpx;
  233. }
  234. .use {
  235. font-size: 26rpx;
  236. color: #FF0000;
  237. }
  238. .use2 {
  239. font-size: 40rpx;
  240. font-weight: 500;
  241. color: #FF0000;
  242. line-height: 56rpx;
  243. }
  244. .used {
  245. font-size: 26rpx;
  246. color: #666666;
  247. }
  248. .used2 {
  249. font-size: 40rpx;
  250. font-weight: 500;
  251. color: #666666;
  252. line-height: 56rpx;
  253. }
  254. .rightB{
  255. position: relative;
  256. }
  257. .tiaojian{
  258. font-size: 24rpx;
  259. color: #666666;
  260. }
  261. .name{
  262. font-size: 30rpx;
  263. display: flex;
  264. font-weight: 500;
  265. color: #333333;
  266. line-height: 42rpx;
  267. }
  268. .time{
  269. font-size: 24rpx;
  270. color: #666666;
  271. margin-top: 15rpx;
  272. }
  273. .itemBottom {
  274. display: flex;
  275. justify-content: space-between;
  276. font-size: 24rpx;
  277. color: #999999;
  278. line-height: 33rpx;
  279. }
  280. .couponlineTopImg{
  281. width: 118rpx;
  282. height: 100rpx;
  283. position: absolute;
  284. top: -38rpx;
  285. right: 0;
  286. }
  287. .shareB{
  288. display: flex;
  289. flex-direction: column;
  290. align-items: center;
  291. }
  292. .couponlineshareImg{
  293. width: 44rpx;
  294. height: 44rpx;
  295. }
  296. .keshare{
  297. font-size: 22rpx;
  298. color: #666666;
  299. margin-top: 15rpx;
  300. }
  301. .rightJian{
  302. display: flex;
  303. align-items: center;
  304. }
  305. </style>