discountCard.vue 6.7 KB

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