discountCard.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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="leftB" v-if="item.discountType==1 " style="display: flex;align-items: center;justify-content: center;">
  16. <view>
  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>
  22. <view class="leftB" v-if="item.discountType!=1" style="display: flex;align-items: center;justify-content: center;">
  23. <image src="http://dmsphoto.66km.com.cn/thFiles/5340A784-FEE2-43FA-8ED1-C509FADFDBED.png"
  24. mode="" style="width: 77rpx;height:48rpx;"></image>
  25. </view>
  26. <view style="width: 460rpx;">
  27. <view class="itemTop">
  28. <view class="centerB">
  29. <view class="name" >
  30. <span class="djq" v-if="item.discountType==1">代金券</span>
  31. <span class="djq" v-if="item.discountType==2">商品券</span>
  32. <span class="djq" v-if="item.discountType==3">服务券</span>
  33. <span>{{item.actName}}</span>
  34. </view>
  35. <view class="plateNumer" v-if="item.plateNumer">限鲁{{item.plateNumer}}使用</view>
  36. <view class="time" v-if="item.startTime">有效期:{{item.startTime.slice(0,10)}}至{{item.endTime.slice(0,10)}}</view>
  37. <view class="time" v-else>有效期:领取后{{item.endOffsetDays}}天</view>
  38. </view>
  39. <view class="rightB">
  40. <image src="../../static/img/icon_yishiyong.png" mode="" v-if="item.state==2&&tabIndex==1" class="couponlineTopImg"></image>
  41. <image src="../../static/img/icon_guoqi.png" mode="" v-if="item.state==1&&tabIndex==1" class="couponlineTopImg"></image>
  42. <!-- <view class="shareB" v-if="item.shareQty>0&&tabIndex==2" @click.stop="">
  43. <image src="../../static/img/icon_share.png" alt="" class="couponlineshareImg"></image>
  44. <view class="keshare">赠送给好友</view>
  45. </view> -->
  46. </view>
  47. </view>
  48. <view class="itemBottom" @click.stop="">
  49. <view class="rightJian">使用规则
  50. <image src="../../static/img/little_rightArrow.png" mode="" style="width: 24rpx;height: 24rpx;"></image>
  51. </view>
  52. <view class="gouse" v-if="item.state==0" @click="goUseFn(item)">去使用</view>
  53. </view>
  54. </view>
  55. <!-- <view class="itemBottom">
  56. <view></view>
  57. <view @click="goDetail(item.id)" class="rightJian">查看详情
  58. <image src="../../static/img/little_rightArrow.png" mode="" style="width: 24rpx;height: 24rpx;"></image>
  59. </view>
  60. </view> -->
  61. </view>
  62. <!-- 无数据空白页 -->
  63. <nodata v-if="items.length==0"></nodata>
  64. </view>
  65. <!-- 核销码 -->
  66. <view class="authorizBox" v-if="hxShow" @click="hxclose">
  67. <view class="hxBox" @click.stop="">
  68. <view class="chBox">
  69. <img src="../../static/timg/chahao.png" alt="" class="chahaoImg" @click="hxclose"/>
  70. </view>
  71. <view class="hxName">{{detail.actName}}</view>
  72. <view class="hxTime" v-if="detail.startTime">
  73. 有效期:{{detail.startTime.slice(0,10)}}至{{detail.endTime.slice(0,10)}}</view>
  74. <view class="hxTime" v-else>有效期:领取后{{detail.endOffsetDays}}天</view>
  75. <view style="display: flex;justify-content: center;padding-top:50rpx;">
  76. <tki-qrcode cid="qrcode1" ref="qrcode" :val="detail.couponCode" :size="400" :unit="unit"
  77. :pdground="pdground" :icon="icon" :iconSize="iconsize" :lv="lv" :onval="onval"
  78. :loadMake="loadMake" :usingComponents="true" @result="qrR" />
  79. </view>
  80. <view class="couponCode">{{detail.couponCode}}</view>
  81. <view class="couponCodeTs">请到店出示券码即可开始服务</view>
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import nodata from '@/components/nodata/nodata.vue'
  88. import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
  89. export default {
  90. components: {
  91. nodata,tkiQrcode
  92. },
  93. computed: {
  94. currentList () {
  95. if (this.tabIndex == 2) {
  96. return this.items.filter(item => ~~item.shareQty > 0)
  97. } else {
  98. return this.items.filter(item => item.state == this.tabIndex2)
  99. }
  100. }
  101. },
  102. data() {
  103. return {
  104. tabIndex: 1,
  105. tabIndex2: 0,
  106. items: [],
  107. onval: true, // val值变化时自动重新生成二维码
  108. loadMake: true, // 组件加载完成后自动生成二维码
  109. val: '二维码', // 要生成的二维码值
  110. unit: 'upx', // 单位
  111. background: '#b4e9e2', // 背景色
  112. foreground: '#309286', // 前景色
  113. pdground: '#262637', // 角标色
  114. icon: '', // 二维码图标
  115. iconsize: 40, // 二维码图标大小
  116. lv: 3, // 二维码容错级别 , 一般不用设置,默认就行
  117. src: '', // 二维码生成后的图片地址或base64
  118. hxShow:false,
  119. detail:'',
  120. }
  121. },
  122. onLoad(opt) {
  123. this.tabIndex = opt.num;
  124. this.myOrderCoupon()
  125. },
  126. onShow() {
  127. console.log(this.tabIndex)
  128. this.myOrderCoupon()
  129. },
  130. methods: {
  131. goDetail(id) {
  132. uni.navigateTo({
  133. url: 'discountCardDetail?id=' + id
  134. })
  135. },
  136. hxclose(){
  137. this.hxShow=false;
  138. },
  139. goUseFn(item){
  140. this.detail=item;
  141. this.hxShow=true;
  142. },
  143. tabClick(num) {
  144. this.tabIndex = num;
  145. },
  146. tabClick2(num) {
  147. this.tabIndex2 = num;
  148. },
  149. myOrderCoupon() {
  150. uni.showLoading({
  151. title: '加载中'
  152. })
  153. this.$http('opencoupon/listCoupon', {
  154. // page: this.page,
  155. // limit: 10,
  156. }, 'POST').then(res => {
  157. uni.hideLoading();
  158. // var list = res.data.Items
  159. var list = res.data
  160. // 处理 undefined和null转为空白字符串
  161. // list.forEach((item, index) => {
  162. // for (const key in item) {
  163. // item[key] = this.$praseStrEmpty(item[key])
  164. // }
  165. // })
  166. this.items = list
  167. })
  168. },
  169. }
  170. }
  171. </script>
  172. <style scoped>
  173. .box {
  174. min-height: 100vh;
  175. background: #F4F5F7;
  176. }
  177. .djq{
  178. background: linear-gradient(128deg, #FFE4C5 0%, #FDC692 100%);
  179. border-radius: 4rpx;
  180. height: 34rpx;
  181. width: 76rpx;
  182. line-height: 34rpx;
  183. text-align: center;
  184. color: #2B2219;
  185. font-size: 20rpx;
  186. margin-top: 4rpx;
  187. margin-right: 10rpx;
  188. }
  189. .plateNumer{
  190. color: #FF0000;
  191. line-height: 30rpx;
  192. font-size: 22rpx;
  193. padding: 3rpx 0rpx;
  194. width: 193rpx;
  195. text-align: center;
  196. background: rgba(255,0,0,0.06);
  197. border-radius: 4rpx;
  198. margin-top: 10rpx;
  199. }
  200. .gouse{
  201. width: 99rpx;
  202. height: 44rpx;
  203. border-radius: 22rpx;
  204. border: 1px solid #FF0000;
  205. text-align: center;
  206. line-height: 42rpx;
  207. color: #FF0000;
  208. }
  209. .tab {
  210. background: #FFFFFF;
  211. display: flex;
  212. justify-content: space-around;
  213. line-height: 92rpx;
  214. position: fixed;
  215. width: calc(100vw - 48rpx);
  216. padding-left: 24rpx;
  217. padding-right: 24rpx;
  218. height: 92rpx;
  219. z-index: 11;
  220. }
  221. .tabLine {
  222. font-size: 30rpx;
  223. text-align: center;
  224. }
  225. .tabActive {
  226. color: #FF0000;
  227. border-bottom: 4rpx solid #FF0000;
  228. }
  229. .main {
  230. /* padding-top: 92rpx; */
  231. padding-bottom: 20rpx;
  232. background-color: #F4F5F7;
  233. }
  234. .mainActive{
  235. /* padding-top: 184rpx; */
  236. padding-bottom: 20rpx;
  237. background-color: #F4F5F7;
  238. }
  239. .okBox {
  240. background: #FFFFFF;
  241. display: flex;
  242. justify-content: flex-start;
  243. align-items: center;
  244. /* border-top: 1rpx solid #EEEEEE; */
  245. position: fixed;
  246. width: 100vw;
  247. padding-left: 24rpx;
  248. padding-right: 24rpx;
  249. /* margin-top: -93rpx; */
  250. height: 92rpx;
  251. z-index: 11;
  252. }
  253. .tabLine2 {
  254. font-size: 28rpx;
  255. text-align: center;
  256. width: 144rpx;
  257. height: 56rpx;
  258. background: #F4F5F7;
  259. border-radius: 28rpx;
  260. line-height: 56rpx;
  261. margin-right: 24rpx;
  262. }
  263. .tabActive2 {
  264. background-color: rgba(240, 59, 59, 0.06);
  265. border-radius: 28rpx;
  266. background-color: 0.06;
  267. font-size: 28rpx;
  268. color: #FF0000;
  269. width: 144rpx;
  270. height: 56rpx;
  271. line-height: 56rpx;
  272. margin-right: 24rpx;
  273. }
  274. .itemBg {
  275. margin: 20rpx 24rpx 0rpx;
  276. background-color: #FFFFFF;
  277. border-radius: 10rpx;
  278. padding: 24rpx 20rpx 20rpx;
  279. display: flex;
  280. }
  281. .leftB{
  282. width: 200rpx;
  283. }
  284. .itemTop {
  285. display: flex;
  286. justify-content: space-between;
  287. margin-bottom: 12rpx;
  288. }
  289. .use {
  290. text-align: center;
  291. font-size: 26rpx;
  292. color: #FF0000;
  293. }
  294. .use2 {
  295. padding-right: 8rpx;
  296. font-size: 40rpx;
  297. font-weight: 500;
  298. color: #FF0000;
  299. line-height: 56rpx;
  300. }
  301. .used {
  302. font-size: 26rpx;
  303. color: #666666;
  304. }
  305. .used2 {
  306. font-size: 40rpx;
  307. font-weight: 500;
  308. color: #666666;
  309. line-height: 56rpx;
  310. }
  311. .rightB{
  312. position: relative;
  313. }
  314. .tiaojian{
  315. font-size: 24rpx;
  316. color: #666666;
  317. }
  318. .name{
  319. font-size: 30rpx;
  320. display: flex;
  321. font-weight: 500;
  322. color: #333333;
  323. line-height: 42rpx;
  324. }
  325. .time{
  326. font-size: 24rpx;
  327. color: #666666;
  328. margin-top: 10rpx;
  329. }
  330. .itemBottom {
  331. display: flex;
  332. justify-content: space-between;
  333. font-size: 24rpx;
  334. color: #999999;
  335. line-height: 33rpx;
  336. }
  337. .couponlineTopImg{
  338. width: 118rpx;
  339. height: 100rpx;
  340. position: absolute;
  341. top: -24rpx;
  342. right: 0;
  343. }
  344. .shareB{
  345. display: flex;
  346. flex-direction: column;
  347. align-items: center;
  348. }
  349. .couponlineshareImg{
  350. width: 44rpx;
  351. height: 44rpx;
  352. }
  353. .keshare{
  354. font-size: 22rpx;
  355. color: #666666;
  356. margin-top: 15rpx;
  357. }
  358. .rightJian{
  359. display: flex;
  360. align-items: center;
  361. }
  362. .authorizBox{
  363. width: 100vw;
  364. height: 100vh;
  365. background: rgba(0, 0, 0, 0.5);
  366. position: fixed;
  367. top: 0;
  368. left: 0;
  369. z-index: 11;
  370. }
  371. .hxBox{
  372. width: 750rpx;
  373. height: 75vh;
  374. margin-top: 25vh;
  375. background: #FFFFFF;
  376. border-radius: 32rpx 32rpx 0rpx 0rpx;
  377. z-index: 222;
  378. }
  379. .couponCode{
  380. font-weight: 500;
  381. color: #333333;
  382. font-size: 30rpx;
  383. padding-top: 40rpx;
  384. text-align: center;
  385. }
  386. .couponCodeTs{
  387. color: #666666;font-size: 24rpx;
  388. text-align: center;padding-top: 10rpx;
  389. }
  390. .hxName{
  391. font-weight: 500;
  392. color: #333333;
  393. line-height: 42rpx;
  394. font-size: 30rpx;
  395. text-align: center;
  396. padding-top: 26rpx;
  397. }
  398. .hxTime{
  399. color: #3C3C3C;font-size: 24rpx; text-align: center;padding-top: 16rpx;
  400. padding-bottom: 50rpx;
  401. border-bottom: 1px dashed #C3C3C3;
  402. }
  403. .chahaoImg{
  404. width: 36rpx;height: 36rpx;
  405. }
  406. .chBox{
  407. text-align: right;
  408. padding-top: 33rpx;
  409. padding-right: 24rpx;
  410. }
  411. .couponCodeBox{
  412. display: flex;
  413. padding-top: 15rpx;
  414. }
  415. </style>