coupon.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <template>
  2. <view ref="container">
  3. <view class="top-fixed">
  4. <view class="search-cont">
  5. <view class="inner">
  6. <image class="icon-search" src="https://kntobs.jnmyunl.com/shop/images/search.png" mode=""></image>
  7. <input type="text" v-model="searchValue" placeholder="输入关键字搜索" confirm-type="search" @confirm="doSearch" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  8. </view>
  9. </view>
  10. <view class="cate-list">
  11. <!-- 关键字列表 -->
  12. <scroll-view scroll-x="true" >
  13. <view class="inner">
  14. <view v-for="(item,index) in cates" :key="index" :class="cateId == item.dictValue?'item active':'item'" @click="choseCate(item)">
  15. {{ item.dictLabel }}
  16. </view>
  17. </view>
  18. </scroll-view>
  19. </view>
  20. </view>
  21. <mescroll-body top="100rpx" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  22. <view class="tui-coupon-list">
  23. <view class="tui-coupon-item tui-top20" v-for="(item, index) in couponsList" :key="index">
  24. <image src="https://kntobs.jnmyunl.com/shop/images/bg_coupon_3x.png" class="tui-coupon-bg" mode="widthFix"></image>
  25. <view class="tui-coupon-item-left">
  26. <view class="tui-coupon-price-box" :class="{ 'tui-color-grey': item.receiveCount>0 }">
  27. <view class="tui-coupon-price-sign">¥</view>
  28. <view class="tui-coupon-price" :class="{ 'tui-price-small': false }">{{ item.couponPrice }}</view>
  29. </view>
  30. <view class="tui-coupon-intro">满{{ item.useMinPrice }}元可用</view>
  31. </view>
  32. <view class="tui-coupon-item-right">
  33. <view class="tui-coupon-content">
  34. <view class="tui-coupon-title-box">
  35. <view class="tui-coupon-title">{{ item.couponName }}</view>
  36. </view>
  37. <view class="tui-coupon-rule">
  38. <view class="tui-rule-box tui-padding-btm">
  39. <view class="tui-coupon-circle"></view>
  40. <view class="tui-coupon-text">不可叠加使用</view>
  41. </view>
  42. <view class="tui-rule-box">
  43. <view class="tui-coupon-circle"></view>
  44. <view class="tui-coupon-text">{{ item.limitTime }} 到期</view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="tui-btn-box">
  50. <view class="btn cancel" @click="showpop(item)">发送</view>
  51. <view class="btn receive" @click="show(item)">查看</view>
  52. </view>
  53. </view>
  54. </view>
  55. </mescroll-body>
  56. <!-- <Loading :loaded="loadend" :loading="loading"></Loading> -->
  57. <!--暂无优惠券-->
  58. <view v-if="couponsList.length == 0 && page > 1" class="no-data-box" >
  59. <image src="https://kntobs.jnmyunl.com/shop/images/no_data.png" mode="aspectFit"></image>
  60. <view class="empty-title">暂无数据</view>
  61. </view>
  62. <view>
  63. <u-popup :show="popshow" @close="close" :closeOnClickOverlay='true'>
  64. <view class="popbox">
  65. <view class="pop-tit">
  66. <view class="poptitle">选择用户</view>
  67. <u-icon name="close" size="24" @click="close"></u-icon>
  68. </view>
  69. <view class="popsh">
  70. <u-search :showAction="true" actionText="搜索" placeholder="输入手机号搜索"
  71. :animation="true" v-model="keyword" @search='searchkey(value)' @custom='searchkey(value)'></u-search>
  72. </view>
  73. <view class="poplist">
  74. <view class="list-box" v-for="(item,index) in phoneUser" :key="index">
  75. <view class="tit">{{item.name}}</view>
  76. <view class="send" @click="sendpop(item.id)">发送</view>
  77. </view>
  78. </view>
  79. </view>
  80. </u-popup>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import {getPackagCateList} from '@/api/storeProductPackage.js'
  86. import { getCompanyCouponIssueList, receive,sendCoupon,searchUser} from '@/api/coupon'
  87. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  88. import Loading from '@/components/Loading'
  89. export default {
  90. name: 'getCoupon',
  91. components: {
  92. Loading,
  93. },
  94. props: {},
  95. mixins: [MescrollMixin],
  96. data: function() {
  97. return {
  98. cateId:0,
  99. cates:[],
  100. page: 1,
  101. limit: 7,
  102. couponsList: [],
  103. loading: false,
  104. loadend: false,
  105. popshow:false,
  106. keyword:'',
  107. detailsid:{},
  108. CompanyUserInfo:{},
  109. user:{},
  110. phoneUser:{},
  111. downOption: { //下拉刷新
  112. use:true,
  113. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  114. },
  115. upOption: {
  116. onScroll:true,
  117. use: true, // 是否启用上拉加载; 默认true
  118. auto: false,
  119. page: {
  120. num:0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  121. size: 7 // 每页数据的数量,默认10
  122. },
  123. noMoreSize: 7, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  124. empty: {
  125. icon:'https://kntobs.jnmyunl.com/shop/images/no_data.png',
  126. tip: '暂无数据'
  127. },
  128. textNoMore:'已经到底了'
  129. },
  130. mescroll:null,
  131. downOption:{
  132. },
  133. searchValue:'',
  134. }
  135. },
  136. onLoad(options) {
  137. // var cate={dictLabel:"全部",dictValue:0};
  138. // this.cates.push(cate);
  139. // this.cates=this.cates.concat(this.utils.getDict("storeProductPackageCate"));
  140. this.getPackagCateList()
  141. },
  142. onShow() {
  143. this.CompanyUserInfo=uni.getStorageSync('CompanyUserInfo');
  144. this.user=uni.getStorageSync('userInfo');
  145. },
  146. methods: {
  147. getPackagCateList(type){
  148. var data={
  149. companyUserToken:uni.getStorageSync('CompanyUserToken'),
  150. appId:wx.getAccountInfoSync().miniProgram.appId
  151. }
  152. var that=this;
  153. this.cates = []
  154. getPackagCateList(data).then(
  155. res => {
  156. if(res.code==200&&res.data&&res.data.length>0){
  157. this.cates=res.data;
  158. this.cateId = res.data[0].dictValue;
  159. this.mescroll&&this.mescroll.resetUpScroll()
  160. }else {
  161. this.cateId = 0
  162. this.couponsList = []
  163. }
  164. },
  165. err => {
  166. }
  167. );
  168. },
  169. doSearch(){
  170. console.log(this.searchValue)
  171. this.mescroll.resetUpScroll()
  172. },
  173. mescrollInit(mescroll) {
  174. this.mescroll = mescroll;
  175. },
  176. /*下拉刷新的回调 */
  177. downCallback(mescroll) {
  178. mescroll.resetUpScroll()
  179. },
  180. searchkey(value){
  181. console.log(this.keyword);
  182. searchUser({value:this.keyword}).then(res=>{
  183. if(res.code==200){
  184. this.phoneUser=res.rows
  185. console.log(res)
  186. }else{
  187. uni.showToast({
  188. icon:'none',
  189. title: res.msg,
  190. });
  191. }
  192. })
  193. },
  194. close(){
  195. this.popshow=false
  196. },
  197. show(item){
  198. uni.navigateTo({
  199. url: '../couponDetails?id=' +item.id
  200. })
  201. },
  202. sendpop(id){
  203. this.sendCoupon(id)
  204. },
  205. sendCoupon(id){
  206. const data={
  207. id:this.detailsid.id,
  208. companyUserId:this.CompanyUserInfo.userId,
  209. companyId:this.CompanyUserInfo.companyId,
  210. setSendUserId:this.user.userId,
  211. userId:id,
  212. companyUserToken:uni.getStorageSync('CompanyUserToken')
  213. }
  214. sendCoupon(data).then(res=>{
  215. if(res.code==200){
  216. uni.showToast({
  217. icon:'none',
  218. title: '发送成功!',
  219. });
  220. }else{
  221. uni.showToast({
  222. icon:'none',
  223. title: res.msg,
  224. });
  225. }
  226. })
  227. },
  228. showpop(item){
  229. this.popshow=true
  230. this.detailsid=item
  231. console.log(item)
  232. },
  233. choseCate(item){
  234. this.cateId = item.dictValue;
  235. // this.couponsList=[];
  236. // this.loading=false;
  237. // this.loadend=false;
  238. // this.page=1;
  239. // this.upCallback();
  240. this.mescroll.resetUpScroll()
  241. },
  242. show(item){
  243. uni.navigateTo({
  244. url: './couponDetails?id=' +item.id
  245. })
  246. },
  247. upCallback(page) {
  248. if(!this.cateId){
  249. this.couponsList = []
  250. this.mescroll.endBySize(0, 0);
  251. return
  252. }
  253. if (this.loading) return //阻止下次请求(false可以进行请求);
  254. if (this.loadend) return //阻止结束当前请求(false可以进行请求);
  255. this.loading = true
  256. var that = this;
  257. let q = { couponType:1,page: page.num, pageSize: page.size,cateId:this.cateId,couponName:this.searchValue }
  258. getCompanyCouponIssueList(q).then(res => {
  259. if(res.code==200){
  260. //设置列表数据
  261. this.loading = false
  262. if ( page.num == 1) {
  263. that.couponsList = res.data.list;
  264. } else {
  265. that.couponsList = that.couponsList.concat(res.data.list);
  266. }
  267. that.mescroll.endBySize(res.data.list.length, res.data.total);
  268. }else{
  269. uni.showToast({
  270. icon:'none',
  271. title: "请求失败",
  272. });
  273. that.couponsList = null;
  274. that.mescroll.endErr();
  275. }
  276. // this.couponsList.push.apply(this.couponsList, res.data.list)
  277. // this.loadend = res.data.list.length < this.limit //判断所有数据是否加载完成;
  278. // this.page = this.page + 1
  279. })
  280. },
  281. },
  282. }
  283. </script>
  284. <style lang="less" scoped>
  285. .search-cont{
  286. padding: 16upx 30upx;
  287. background-color: #FFFFFF;
  288. .inner{
  289. box-sizing: border-box;
  290. width: 100%;
  291. height: 72upx;
  292. background: #F7F7F7;
  293. border-radius: 36upx;
  294. display: flex;
  295. align-items: center;
  296. padding: 0 30upx;
  297. .icon-search{
  298. width: 28upx;
  299. height: 28upx;
  300. margin-right: 20upx;
  301. }
  302. input{
  303. height: 60upx;
  304. line-height: 60upx;
  305. flex: 1;
  306. }
  307. }
  308. }
  309. .popbox{
  310. padding: 20rpx;
  311. height: 400rpx;
  312. .poplist{
  313. margin-top: 20rpx;
  314. .list-box{
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: center;
  318. .tit{
  319. font-size:24rpx;
  320. color: #666;
  321. }
  322. .send{
  323. width: 122rpx;
  324. height: 50rpx;
  325. line-height: 50rpx;
  326. font-size: 26upx;
  327. font-family: PingFang SC;
  328. font-weight: 500;
  329. text-align: center;
  330. border-radius: 32upx;
  331. margin-left: 15upx;
  332. border: 1px solid #2BC7B9;
  333. color: #2BC7B9;
  334. }
  335. }
  336. }
  337. }
  338. .pop-tit{
  339. display: flex;
  340. padding: 20rpx;
  341. .poptitle{
  342. flex: 1;
  343. text-align: center;
  344. }
  345. }
  346. page {
  347. background-color: #f5f5f5;
  348. }
  349. .container {
  350. padding-bottom: env(safe-area-inset-bottom);
  351. }
  352. .top-fixed{
  353. width: 100%;
  354. position: fixed;
  355. top: 0;
  356. left: 0;
  357. z-index: 99999;
  358. .cate-list{
  359. box-sizing: border-box;
  360. background: #fff;
  361. padding: 10upx 27upx;
  362. height: 100upx;
  363. .inner{
  364. display: flex;
  365. }
  366. .item{
  367. flex-shrink: 0;
  368. padding: 0 24upx;
  369. height: 64upx;
  370. line-height: 64upx;
  371. font-size: 28upx;
  372. font-family: PingFang SC;
  373. font-weight: 500;
  374. color: #2BC7B9;
  375. background: #F5FFFE;
  376. border: 1px solid #8AD5CE;
  377. border-radius: 32upx;
  378. margin: 0 20upx 20upx 0;
  379. &.active{
  380. color: #FFFFFF;
  381. background: #2BC7B9;
  382. border: 1px solid #2BC7B9;
  383. }
  384. }
  385. }
  386. }
  387. .tui-coupon-list {
  388. margin-top: 120upx;
  389. width: 100%;
  390. padding: 0 25rpx;
  391. box-sizing: border-box;
  392. }
  393. .tui-coupon-banner {
  394. width: 100%;
  395. }
  396. .tui-coupon-item {
  397. width: 100%;
  398. height: 210rpx;
  399. position: relative;
  400. display: flex;
  401. align-items: center;
  402. padding-right: 30rpx;
  403. box-sizing: border-box;
  404. overflow: hidden;
  405. }
  406. .tui-coupon-bg {
  407. width: 100%;
  408. height: 210rpx;
  409. position: absolute;
  410. left: 0;
  411. top: 0;
  412. z-index: 1;
  413. }
  414. .tui-coupon-sign {
  415. height: 110rpx;
  416. width: 110rpx;
  417. position: absolute;
  418. z-index: 9;
  419. top: -30rpx;
  420. right: 40rpx;
  421. }
  422. .tui-coupon-item-left {
  423. width: 218rpx;
  424. height: 210rpx;
  425. position: relative;
  426. z-index: 2;
  427. display: flex;
  428. align-items: center;
  429. justify-content: center;
  430. flex-direction: column;
  431. flex-shrink: 0;
  432. }
  433. .tui-coupon-price-box {
  434. display: flex;
  435. color: #e41f19;
  436. align-items: flex-end;
  437. }
  438. .tui-coupon-price-sign {
  439. font-size: 30rpx;
  440. }
  441. .tui-coupon-price {
  442. font-size: 70rpx;
  443. line-height: 68rpx;
  444. font-weight: bold;
  445. }
  446. .tui-price-small {
  447. font-size: 58rpx !important;
  448. line-height: 56rpx !important;
  449. }
  450. .tui-coupon-intro {
  451. background: #f7f7f7;
  452. padding: 8rpx 10rpx;
  453. font-size: 26rpx;
  454. line-height: 26rpx;
  455. font-weight: 400;
  456. color: #666;
  457. margin-top: 18rpx;
  458. }
  459. .tui-coupon-item-right {
  460. flex: 1;
  461. height: 210rpx;
  462. position: relative;
  463. z-index: 2;
  464. display: flex;
  465. align-items: center;
  466. justify-content: space-between;
  467. padding-left: 24rpx;
  468. box-sizing: border-box;
  469. overflow: hidden;
  470. }
  471. .tui-coupon-content {
  472. width: 82%;
  473. display: flex;
  474. flex-direction: column;
  475. justify-content: center;
  476. }
  477. .tui-coupon-title-box {
  478. display: flex;
  479. align-items: center;
  480. }
  481. .tui-coupon-btn {
  482. padding: 6rpx;
  483. background: #ffebeb;
  484. color: #e41f19;
  485. font-size: 25rpx;
  486. line-height: 25rpx;
  487. display: flex;
  488. align-items: center;
  489. justify-content: center;
  490. transform: scale(0.9);
  491. transform-origin: 0 center;
  492. border-radius: 4rpx;
  493. flex-shrink: 0;
  494. }
  495. .tui-color-grey {
  496. color: #888 !important;
  497. }
  498. .tui-bg-grey {
  499. background: #f0f0f0 !important;
  500. color: #888 !important;
  501. }
  502. .tui-coupon-title {
  503. width: 100%;
  504. font-size: 26rpx;
  505. color: #333;
  506. white-space: nowrap;
  507. overflow: hidden;
  508. text-overflow: ellipsis;
  509. }
  510. .tui-coupon-rule {
  511. padding-top: 52rpx;
  512. }
  513. .tui-rule-box {
  514. display: flex;
  515. align-items: center;
  516. transform: scale(0.8);
  517. transform-origin: 0 100%;
  518. }
  519. .tui-padding-btm {
  520. padding-bottom: 6rpx;
  521. }
  522. .tui-coupon-circle {
  523. width: 8rpx;
  524. height: 8rpx;
  525. background: rgb(160, 160, 160);
  526. border-radius: 50%;
  527. }
  528. .tui-coupon-text {
  529. font-size: 28rpx;
  530. line-height: 28rpx;
  531. font-weight: 400;
  532. color: #666;
  533. padding-left: 8rpx;
  534. white-space: nowrap;
  535. }
  536. .tui-top20 {
  537. margin-top: 20rpx;
  538. }
  539. .tui-coupon-title {
  540. font-size: 28rpx;
  541. line-height: 28rpx;
  542. }
  543. .tui-coupon-radio {
  544. transform: scale(0.7);
  545. transform-origin: 100% center;
  546. }
  547. .tui-btn-box {
  548. position: absolute;
  549. right: 20rpx;
  550. bottom: 40rpx;
  551. z-index: 10;
  552. .btn{
  553. width: 155upx;
  554. height: 64upx;
  555. line-height: 64upx;
  556. font-size: 26upx;
  557. font-family: PingFang SC;
  558. font-weight: 500;
  559. text-align: center;
  560. border-radius: 32upx;
  561. margin-left: 15upx;
  562. &.cancel{
  563. border: 1px solid #2BC7B9;
  564. color: #2BC7B9;
  565. margin-bottom: 12rpx;
  566. }
  567. &.receive{
  568. background: #2BC7B9;
  569. color: #FFFFFF;
  570. }
  571. }
  572. }
  573. </style>