hexiao_coupon.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <view class="index-page">
  3. <view class="content-wrap color-white">
  4. <view class="scan-code" @click="saoma">
  5. <view class="label">扫码核销霸王餐券</view>
  6. <u-icon name="scan" size="24" color="#666"></u-icon>
  7. </view>
  8. <!-- <swiper-item class="swiper-box1"> -->
  9. <scroll-view scroll-y class="scroll-order-list" @scrolltolower="scrolltolower">
  10. <view class="order-list">
  11. <view class="item" v-for="item in couponList" :key="item.raffleRecordId">
  12. <view class="goods-wrap">
  13. <image class="goods-cover" :src="item.pictureUrl" />
  14. <view class="cont">
  15. <view class="row">
  16. <view class="label">霸王餐标题:{{item.title}}</view>
  17. </view>
  18. <view class="row">
  19. <view class="label">奖品:{{item.goodsName}}</view>
  20. </view>
  21. <view class="row">
  22. <view class="label">兑奖人:{{item.memberName ? item.memberName : ''}}</view>
  23. </view>
  24. <view class="row create-time">
  25. <view class="label">核销时间:</view>
  26. <view class="value">{{ item.useDate }}</view>
  27. </view>
  28. <!--
  29. <view class="row">
  30. <view class="label" v-if="item.takeupCode">取餐码:{{item.takeupCode}}</view>
  31. </view> -->
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view v-if="isShow" class="zanwu column">
  37. <image src="../../static/empty2x.png" style="width: 280upx;height: auto" mode="widthFix">
  38. </image>
  39. 暂无数据
  40. </view>
  41. <uni-load-more :status="loadingType_status" v-if="ismore"></uni-load-more>
  42. </scroll-view>
  43. <!-- </swiper-item> -->
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import uniPopup from "@/components/uni-popup/uni-popup.vue"
  49. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  50. import {mapState} from 'vuex';
  51. export default {
  52. components: {
  53. uniPopup,
  54. uniLoadMore
  55. },
  56. data() {
  57. return {
  58. listUrl: '/storeHeXiaoApi/getCouponList',
  59. checkUrl: '/storeHeXiaoApi/hxCheck',
  60. cancelurl: '/storeHeXiaoApi/surePassStoreGoods',
  61. flag: false,
  62. isDisable1: false,
  63. page: 1,
  64. couponList: [],
  65. loadingType: 0,
  66. isShow: false,
  67. ismore: false,
  68. loadingType_status: 'more',
  69. errorMsg: ''
  70. };
  71. },
  72. onLoad() {
  73. },
  74. onShow() {
  75. this.loadData(this.errorMsg);
  76. },
  77. computed: {
  78. ...mapState(['storeInfo'])
  79. },
  80. methods: {
  81. navTo(url){
  82. uni.navigateTo({
  83. url:url
  84. })
  85. },
  86. loadData(msg) {
  87. uni.showLoading({
  88. title: '加载中'
  89. });
  90. this.isShow = false
  91. this.ismore = false;
  92. var dateStr = (new Date()).getTime();
  93. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  94. this.requst({
  95. url: this.listUrl,
  96. data: {
  97. storeId: this.storeInfo.storeId,
  98. storeUserId: this.storeInfo.storeUserId,
  99. timestamp: dateStr,
  100. sign: sign,
  101. currentPage: 1
  102. },
  103. success: res => {
  104. if (res.data.rtnBean.rtnCode == 0) {
  105. if (res.data.list != null && res.data.list.length > 0) {
  106. if (res.data.list != null && res.data.list.length > 0 && res.data.list
  107. .length <= 20) {
  108. this.couponList = res.data.list;
  109. if (res.data.page.pageCount == 1) {
  110. this.isShow = false
  111. this.loadingType = 2;
  112. this.loadingType_status = 'nomore';
  113. this.ismore = true;
  114. } else {
  115. this.isShow = true
  116. this.loadingType = 0;
  117. this.loadingType_status = 'more';
  118. this.ismore = true;
  119. }
  120. } else {
  121. this.ismore = false;
  122. this.isShow = true
  123. this.loadingType = 2;
  124. }
  125. } else {
  126. this.isShow = true
  127. this.couponList = [];
  128. }
  129. } else {
  130. this.isShow = true
  131. this.orderList = [];
  132. }
  133. uni.stopPullDownRefresh()
  134. uni.hideLoading();
  135. if (msg != '' && msg != undefined && msg != null) {
  136. uni.showToast({
  137. icon: 'none',
  138. title: msg,
  139. duration: 1500
  140. })
  141. }
  142. this.errorMsg = '';
  143. },
  144. fail: (e) => {
  145. console.log("接口调用失败:" + JSON.stringify(e));
  146. uni.stopPullDownRefresh()
  147. uni.hideLoading();
  148. },
  149. })
  150. },
  151. scrolltolower() {
  152. if (this.loadingType != 0) { // loadingType!=0;直接返回
  153. return false
  154. }
  155. this.loadingType_status = 'loading';
  156. this.page = this.page + 1;
  157. this.loadingType = 1;
  158. uni.showLoading({
  159. title: '加载中'
  160. });
  161. var dateStr = (new Date()).getTime();
  162. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  163. this.requst({
  164. url: this.listUrl,
  165. data: {
  166. storeId: this.storeInfo.storeId,
  167. storeUserId: this.storeInfo.storeUserId,
  168. timestamp: dateStr,
  169. sign: signUser,
  170. currentPage: this.page
  171. },
  172. success: res => {
  173. if (res.data.rtnBean.rtnCode == 0) {
  174. if (res.data.list != "" && res.data.list != null && res.data.list.length > 0) {
  175. for (var i = 0; i < res.data.list.length; i++) {
  176. this.couponList.push(res.data.list[i]);
  177. }
  178. if (res.data.page.currentPage == res.data.page.pageCount) {
  179. this.loadingType = 2;
  180. this.loadingType_status = 'more'
  181. this.ismore = false;
  182. }else {
  183. this.isShow = false
  184. this.loadingType = 0;
  185. this.loadingType_status = 'more';
  186. this.ismore = true;
  187. }
  188. } else {
  189. this.loadingType_status = 'nomore'
  190. this.loadingType = 2;
  191. this.ismore = false;
  192. }
  193. } else {
  194. if (res.data.rtnBean.rtnMsg != '') {
  195. this.$api.msg(res.data.rtnBean.rtnMsg);
  196. }
  197. }
  198. uni.hideLoading();
  199. },
  200. fail: (e) => {
  201. console.log("接口调用失败:" + JSON.stringify(e));
  202. uni.hideLoading();
  203. },
  204. });
  205. },
  206. saoma() {
  207. uni.showLoading({
  208. title: '加载中'
  209. })
  210. var that = this;
  211. // 只允许从相机扫码
  212. wx.scanCode({
  213. onlyFromCamera: true,
  214. scanType: 'qrCode',
  215. success(res) {
  216. uni.hideLoading()
  217. that.isCouponCode(encodeURIComponent(res.result));
  218. },fail(res) {
  219. uni.hideLoading()
  220. }
  221. })
  222. },
  223. // 判断是不是核销码类型
  224. isCouponCode(secreyKey) {
  225. var dateStr = (new Date()).getTime();
  226. var sign = this.getSign(decodeURIComponent(secreyKey) + this.storeInfo.storeUserId + dateStr);
  227. let that = this
  228. this.requst({
  229. url: this.checkUrl,
  230. data: {
  231. secreyKey: decodeURIComponent(secreyKey),
  232. storeId: this.storeInfo.storeId,
  233. storeUserId: this.storeInfo.storeUserId,
  234. timestamp: dateStr,
  235. sign: sign
  236. },
  237. success: res => {
  238. if (res.data.rtnBean.rtnCode == 0) {
  239. uni.showModal({
  240. title: '提示',
  241. content: '是否确认核销?',
  242. success: function (r) {
  243. if (r.confirm) {
  244. that.cancelCoupon(res.data.obj)
  245. } else if (r.cancel) {
  246. console.log('用户点击取消');
  247. }
  248. }
  249. });
  250. }else {
  251. this.$api.msg(res.data.rtnBean.rtnMsg);
  252. this.errorMsg = res.data.rtnBean.rtnMsg;
  253. return;
  254. }
  255. },
  256. fail: (e) => {
  257. console.log("接口调用失败:" + JSON.stringify(e));
  258. },
  259. })
  260. },
  261. cancelCoupon (e) {
  262. uni.showLoading({
  263. title: '核销中'
  264. })
  265. var dateStr = (new Date()).getTime();
  266. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  267. this.requst({
  268. url: this.cancelurl,
  269. data: {
  270. timestamp: dateStr,
  271. sign: sign,
  272. id: e.raffleRecordId,
  273. storeId: this.storeInfo.storeId,
  274. storeUserId: this.storeInfo.storeUserId
  275. },
  276. success: res => {
  277. if (res.data.rtnBean.rtnCode == 0) {
  278. uni.showToast({
  279. title: '核销成功',
  280. icon: 'none'
  281. })
  282. this.loadData()
  283. } else {
  284. if (res.data.rtnBean.rtnMsg != '') {
  285. this.$api.msg(res.data.rtnBean.rtnMsg);
  286. // return;
  287. }
  288. }
  289. uni.hideLoading()
  290. },
  291. fail: (e) => {
  292. uni.hideLoading()
  293. console.log("接口调用失败:" + JSON.stringify(e));
  294. this.handle = false;
  295. },
  296. });
  297. },
  298. onPullDownRefresh() {
  299. this.loadData();
  300. },
  301. },
  302. }
  303. </script>
  304. <style lang="scss" scoped>
  305. .fs14 {
  306. font-size: $font-base;
  307. }
  308. .pd24 {
  309. padding: 0 24rpx;
  310. box-sizing: border-box;
  311. }
  312. .mlr24 {
  313. margin: 0 24rpx;
  314. }
  315. .ptb10 {
  316. padding: 10rpx 0;
  317. box-sizing: border-box;
  318. }
  319. .mt10 {
  320. margin-top: 10rpx;
  321. }
  322. .mt20 {
  323. margin-top: 20rpx;
  324. }
  325. .mb10 {
  326. margin-bottom: 10rpx;
  327. }
  328. .w100 {
  329. width: 100%;
  330. }
  331. .borbtm {
  332. border-bottom: 2rpx solid #ececec;
  333. }
  334. .text {
  335. color: $text-color;
  336. }
  337. .desc {
  338. color: $desc-color;
  339. }
  340. .index-page {
  341. width: 100vw;
  342. height: 100vh;
  343. background-color: #f5f5f5;
  344. ::-webkit-scrollbar {
  345. display: none;
  346. }
  347. }
  348. /deep/ .input-placeholder {
  349. color: #666666
  350. }
  351. .tabs-wrap {
  352. padding-left: 5vw;
  353. box-sizing: border-box;
  354. background-color: #fff;
  355. position: fixed;
  356. .tabs {
  357. margin-bottom: 20rpx;
  358. }
  359. }
  360. .content-wrap {
  361. height: calc(100vh - 80rpx);
  362. .take-food-wrap {
  363. background-color: #f5f5f5;
  364. }
  365. .scan-code {
  366. @include between;
  367. height: 60rpx;
  368. margin: 0 20rpx 20rpx;
  369. padding: 0 20rpx;
  370. box-sizing: border-box;
  371. background-color: #f5f5f5;
  372. .label {
  373. font-size: $font-base;
  374. color: $icon-color;
  375. }
  376. }
  377. .item-date {
  378. height: 60rpx;
  379. background-color: #f5f5f5;
  380. @include flexStart;
  381. font-size: $font-base;
  382. padding: 0 20rpx;
  383. box-sizing: border-box;
  384. }
  385. .take-food-wrap {
  386. background-color: #fff;
  387. }
  388. .item-food-no {
  389. padding: 0 20rpx;
  390. box-sizing: border-box;
  391. border-bottom: 2rpx solid #ececec;
  392. height: 100rpx;
  393. @include between;
  394. font-size: $font-base;
  395. color: $title-color;
  396. font-weight: bold;
  397. .btn {
  398. font-weight: normal;
  399. width: 140rpx;
  400. height: 52rpx;
  401. background-color: $base-color;
  402. color: #fff;
  403. border-radius: 26rpx;
  404. @include flexCenter;
  405. font-size: $font-sm;
  406. }
  407. }
  408. .btm {
  409. font-size: $font-sm;
  410. color: #6c6c6c;
  411. }
  412. }
  413. .auto-taking-order {
  414. width: 100vw;
  415. height: 80rpx;
  416. @include between;
  417. padding: 0 20rpx;
  418. box-sizing: border-box;
  419. /deep/ .u-switch {
  420. transform: scale(.75) translateX(12rpx);
  421. }
  422. }
  423. .list-scroll-wrap {
  424. width: calc(100vw - 40rpx);
  425. margin-left: 20rpx;
  426. padding-bottom: 20rpx;
  427. }
  428. .color-white {
  429. background-color: #fff;
  430. padding-top: 20rpx;
  431. box-sizing: border-box;
  432. }
  433. .h70 {
  434. .item-food-no {
  435. height: 140rpx;
  436. }
  437. .top {
  438. margin-bottom: 10rpx;
  439. }
  440. }
  441. .swiper-wrap, .swiper-box1, .scroll-order-list {
  442. height: calc(100vh - 120rpx);
  443. }
  444. .order-list {
  445. padding: 20rpx;
  446. box-sizing: border-box;
  447. .item {
  448. background-color: #fff;
  449. border-radius: 20rpx;
  450. overflow: hidden;
  451. margin-bottom: 20rpx;
  452. }
  453. .store-wrap {
  454. border-bottom: 2rpx solid #ececec;
  455. @include between;
  456. height: 100rpx;
  457. padding: 0 20rpx;
  458. box-sizing: border-box;
  459. }
  460. .store-icon {
  461. min-width: 50rpx;
  462. width: 50rpx;
  463. height: 50rpx;
  464. border-radius: 10rpx;
  465. overflow: hidden;
  466. .img {
  467. width: 100%;
  468. height: 100%;
  469. }
  470. }
  471. .pay-state {
  472. width: 140rpx;
  473. min-width: 140rpx;
  474. color: $desc-color;
  475. text-align: right;
  476. font-size: $font-base;
  477. }
  478. .store-name {
  479. margin: 0 10rpx;
  480. @include textOverflow;
  481. }
  482. .goods-wrap {
  483. @include flexStart;
  484. padding: 20rpx 20rpx 0;
  485. box-sizing: border-box;
  486. margin-bottom: 20rpx;
  487. }
  488. .goods-cover {
  489. width: 96rpx;
  490. min-width: 96rpx;
  491. height: 96rpx;
  492. margin-right: 20rpx;
  493. border-radius: 10rpx;
  494. overflow: hidden;
  495. }
  496. .cont {
  497. width: calc(100% - 120rpx);
  498. }
  499. .row {
  500. @include flexStart;
  501. font-size: $font-base;
  502. color: $text-color;
  503. }
  504. .label {
  505. margin-right: 20rpx;
  506. }
  507. .btn-wrap {
  508. display: flex;
  509. justify-content: flex-end;
  510. align-items: center;
  511. margin: 0 20rpx 20rpx 0;
  512. }
  513. .btn {
  514. background-color: $theme-color;
  515. color: #fff;
  516. height: 60rpx;
  517. width: 180rpx;
  518. border-radius: 30rpx;
  519. margin-left: 16rpx;
  520. @include flexCenter;
  521. font-size: $font-base;
  522. }
  523. .btn1 {
  524. // background-color: $theme-color;
  525. color: black;
  526. height: 60rpx;
  527. width: 180rpx;
  528. border: 1px solid #ccc;
  529. border-radius: 30rpx;
  530. margin-left: 16rpx;
  531. @include flexCenter;
  532. font-size: $font-base;
  533. }
  534. }
  535. </style>