discountCard.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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. userInfo:'',
  123. ext:'',
  124. wxOpenData:'',
  125. }
  126. },
  127. onLoad(opt) {
  128. this.tabIndex = opt.num;
  129. this.userInfo=this.$store.state.userInfo;
  130. this.ext=this.$common.getExtStoreId();
  131. if(this.userInfo){
  132. this.myOrderCoupon()
  133. }else{
  134. this.$common.automaticlogin().then(val => {
  135. this.userInfo=this.$store.state.userInfo;
  136. this.myOrderCoupon()
  137. })
  138. }
  139. this.$refs.authoriz.init();
  140. },
  141. onShow() {
  142. console.log(this.tabIndex)
  143. this.myOrderCoupon()
  144. },
  145. methods: {
  146. parentMethod(){
  147. this.myOrderCoupon()
  148. },
  149. goDetail(id) {
  150. uni.navigateTo({
  151. url: 'discountCardDetail?id=' + id
  152. })
  153. },
  154. hxclose(){
  155. this.hxShow=false;
  156. },
  157. goUseFn(item){
  158. this.detail=item;
  159. this.hxShow=true;
  160. },
  161. tabClick(num) {
  162. this.tabIndex = num;
  163. },
  164. tabClick2(num) {
  165. this.tabIndex2 = num;
  166. },
  167. myOrderCoupon() {
  168. uni.showLoading({
  169. title: '加载中'
  170. })
  171. this.$http('opencoupon/listCoupon', {
  172. // page: this.page,
  173. // limit: 10,
  174. }, 'POST').then(res => {
  175. uni.hideLoading();
  176. // var list = res.data.Items
  177. var list = res.data
  178. // 处理 undefined和null转为空白字符串
  179. // list.forEach((item, index) => {
  180. // for (const key in item) {
  181. // item[key] = this.$praseStrEmpty(item[key])
  182. // }
  183. // })
  184. this.items = list
  185. })
  186. },
  187. }
  188. }
  189. </script>
  190. <style scoped>
  191. .box {
  192. min-height: 100vh;
  193. background: #F4F5F7;
  194. }
  195. .djq{
  196. background: linear-gradient(128deg, #FFE4C5 0%, #FDC692 100%);
  197. border-radius: 4rpx;
  198. height: 34rpx;
  199. width: 76rpx;
  200. line-height: 34rpx;
  201. text-align: center;
  202. color: #2B2219;
  203. font-size: 20rpx;
  204. margin-top: 4rpx;
  205. margin-right: 10rpx;
  206. }
  207. .plateNumer{
  208. color: #EC0F0A;
  209. line-height: 30rpx;
  210. font-size: 22rpx;
  211. padding: 3rpx 0rpx;
  212. width: 193rpx;
  213. text-align: center;
  214. background: rgba(255,0,0,0.06);
  215. border-radius: 4rpx;
  216. margin-top: 10rpx;
  217. }
  218. .gouse{
  219. width: 99rpx;
  220. height: 44rpx;
  221. border-radius: 22rpx;
  222. border: 1px solid #EC0F0A;
  223. text-align: center;
  224. line-height: 42rpx;
  225. color: #EC0F0A;
  226. }
  227. .tab {
  228. background: #FFFFFF;
  229. display: flex;
  230. justify-content: space-around;
  231. line-height: 92rpx;
  232. position: fixed;
  233. width: calc(100vw - 48rpx);
  234. padding-left: 24rpx;
  235. padding-right: 24rpx;
  236. height: 92rpx;
  237. z-index: 11;
  238. }
  239. .tabLine {
  240. font-size: 30rpx;
  241. text-align: center;
  242. }
  243. .tabActive {
  244. color: #EC0F0A;
  245. border-bottom: 4rpx solid #EC0F0A;
  246. }
  247. .main {
  248. /* padding-top: 92rpx; */
  249. padding-bottom: 20rpx;
  250. background-color: #F4F5F7;
  251. }
  252. .mainActive{
  253. /* padding-top: 184rpx; */
  254. padding-bottom: 20rpx;
  255. background-color: #F4F5F7;
  256. }
  257. .okBox {
  258. background: #FFFFFF;
  259. display: flex;
  260. justify-content: flex-start;
  261. align-items: center;
  262. /* border-top: 1rpx solid #EEEEEE; */
  263. position: fixed;
  264. width: 100vw;
  265. padding-left: 24rpx;
  266. padding-right: 24rpx;
  267. /* margin-top: -93rpx; */
  268. height: 92rpx;
  269. z-index: 11;
  270. }
  271. .tabLine2 {
  272. font-size: 28rpx;
  273. text-align: center;
  274. width: 144rpx;
  275. height: 56rpx;
  276. background: #F4F5F7;
  277. border-radius: 28rpx;
  278. line-height: 56rpx;
  279. margin-right: 24rpx;
  280. }
  281. .tabActive2 {
  282. background-color: rgba(240, 59, 59, 0.06);
  283. border-radius: 28rpx;
  284. background-color: 0.06;
  285. font-size: 28rpx;
  286. color: #EC0F0A;
  287. width: 144rpx;
  288. height: 56rpx;
  289. line-height: 56rpx;
  290. margin-right: 24rpx;
  291. }
  292. .itemBg {
  293. margin: 20rpx 24rpx 0rpx;
  294. background-color: #FFFFFF;
  295. border-radius: 10rpx;
  296. padding: 24rpx 20rpx 20rpx;
  297. display: flex;
  298. }
  299. .leftB{
  300. width: 200rpx;
  301. }
  302. .itemTop {
  303. display: flex;
  304. justify-content: space-between;
  305. margin-bottom: 12rpx;
  306. }
  307. .use {
  308. text-align: center;
  309. font-size: 26rpx;
  310. color: #EC0F0A;
  311. }
  312. .use2 {
  313. padding-right: 8rpx;
  314. font-size: 40rpx;
  315. font-weight: 500;
  316. color: #EC0F0A;
  317. line-height: 56rpx;
  318. }
  319. .used {
  320. font-size: 26rpx;
  321. color: #666666;
  322. }
  323. .used2 {
  324. font-size: 40rpx;
  325. font-weight: 500;
  326. color: #666666;
  327. line-height: 56rpx;
  328. }
  329. .rightB{
  330. position: relative;
  331. }
  332. .tiaojian{
  333. font-size: 24rpx;
  334. color: #666666;
  335. }
  336. .name{
  337. font-size: 30rpx;
  338. display: flex;
  339. font-weight: 500;
  340. color: #333333;
  341. line-height: 42rpx;
  342. }
  343. .time{
  344. font-size: 24rpx;
  345. color: #666666;
  346. margin-top: 10rpx;
  347. }
  348. .itemBottom {
  349. display: flex;
  350. justify-content: space-between;
  351. font-size: 24rpx;
  352. color: #999999;
  353. line-height: 33rpx;
  354. }
  355. .couponlineTopImg{
  356. width: 118rpx;
  357. height: 100rpx;
  358. position: absolute;
  359. top: -24rpx;
  360. right: 0;
  361. }
  362. .shareB{
  363. display: flex;
  364. flex-direction: column;
  365. align-items: center;
  366. }
  367. .couponlineshareImg{
  368. width: 44rpx;
  369. height: 44rpx;
  370. }
  371. .keshare{
  372. font-size: 22rpx;
  373. color: #666666;
  374. margin-top: 15rpx;
  375. }
  376. .rightJian{
  377. display: flex;
  378. align-items: center;
  379. }
  380. .authorizBox{
  381. width: 100vw;
  382. height: 100vh;
  383. background: rgba(0, 0, 0, 0.5);
  384. position: fixed;
  385. top: 0;
  386. left: 0;
  387. z-index: 11;
  388. }
  389. .hxBox{
  390. width: 750rpx;
  391. height: 75vh;
  392. margin-top: 25vh;
  393. background: #FFFFFF;
  394. border-radius: 32rpx 32rpx 0rpx 0rpx;
  395. z-index: 222;
  396. }
  397. .couponCode{
  398. font-weight: 500;
  399. color: #333333;
  400. font-size: 30rpx;
  401. padding-top: 40rpx;
  402. text-align: center;
  403. }
  404. .couponCodeTs{
  405. color: #666666;font-size: 24rpx;
  406. text-align: center;padding-top: 10rpx;
  407. }
  408. .hxName{
  409. font-weight: 500;
  410. color: #333333;
  411. line-height: 42rpx;
  412. font-size: 30rpx;
  413. text-align: center;
  414. padding-top: 26rpx;
  415. }
  416. .hxTime{
  417. color: #3C3C3C;font-size: 24rpx; text-align: center;padding-top: 16rpx;
  418. padding-bottom: 50rpx;
  419. border-bottom: 1px dashed #C3C3C3;
  420. }
  421. .chahaoImg{
  422. width: 36rpx;height: 36rpx;
  423. }
  424. .chBox{
  425. text-align: right;
  426. padding-top: 33rpx;
  427. padding-right: 24rpx;
  428. }
  429. .couponCodeBox{
  430. display: flex;
  431. padding-top: 15rpx;
  432. }
  433. </style>