discountCard.vue 12 KB

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