discountCard.vue 6.7 KB

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