coupon.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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. var cate={dictLabel:"全部",dictValue:0};
  158. this.cates.push(cate);
  159. this.cates=this.cates.concat(res.data);
  160. this.cateId = 0
  161. this.mescroll&&this.mescroll.resetUpScroll()
  162. } else {
  163. this.cateId = 0
  164. this.dataList = []
  165. }
  166. },
  167. err => {
  168. }
  169. );
  170. },
  171. doSearch(){
  172. console.log(this.searchValue)
  173. this.mescroll.resetUpScroll()
  174. },
  175. mescrollInit(mescroll) {
  176. this.mescroll = mescroll;
  177. },
  178. /*下拉刷新的回调 */
  179. downCallback(mescroll) {
  180. mescroll.resetUpScroll()
  181. },
  182. searchkey(value){
  183. console.log(this.keyword);
  184. searchUser({value:this.keyword}).then(res=>{
  185. if(res.code==200){
  186. this.phoneUser=res.rows
  187. console.log(res)
  188. }else{
  189. uni.showToast({
  190. icon:'none',
  191. title: res.msg,
  192. });
  193. }
  194. })
  195. },
  196. close(){
  197. this.popshow=false
  198. },
  199. show(item){
  200. uni.navigateTo({
  201. url: '../couponDetails?id=' +item.id
  202. })
  203. },
  204. sendpop(id){
  205. this.sendCoupon(id)
  206. },
  207. sendCoupon(id){
  208. const data={
  209. id:this.detailsid.id,
  210. companyUserId:this.CompanyUserInfo.userId,
  211. companyId:this.CompanyUserInfo.companyId,
  212. setSendUserId:this.user.userId,
  213. userId:id,
  214. companyUserToken:uni.getStorageSync('CompanyUserToken')
  215. }
  216. sendCoupon(data).then(res=>{
  217. if(res.code==200){
  218. uni.showToast({
  219. icon:'none',
  220. title: '发送成功!',
  221. });
  222. }else{
  223. uni.showToast({
  224. icon:'none',
  225. title: res.msg,
  226. });
  227. }
  228. })
  229. },
  230. showpop(item){
  231. this.popshow=true
  232. this.detailsid=item
  233. console.log(item)
  234. },
  235. choseCate(item){
  236. this.cateId = item.dictValue;
  237. // this.couponsList=[];
  238. // this.loading=false;
  239. // this.loadend=false;
  240. // this.page=1;
  241. // this.upCallback();
  242. this.mescroll.resetUpScroll()
  243. },
  244. show(item){
  245. uni.navigateTo({
  246. url: './couponDetails?id=' +item.id
  247. })
  248. },
  249. upCallback(page) {
  250. console.log(page)
  251. if (this.loading) return //阻止下次请求(false可以进行请求);
  252. if (this.loadend) return //阻止结束当前请求(false可以进行请求);
  253. this.loading = true
  254. var that = this;
  255. let q = { couponType:1,page: page.num, pageSize: page.size,cateId:this.cateId,couponName:this.searchValue }
  256. getCompanyCouponIssueList(q).then(res => {
  257. if(res.code==200){
  258. //设置列表数据
  259. this.loading = false
  260. if ( page.num == 1) {
  261. that.couponsList = res.data.list;
  262. } else {
  263. that.couponsList = that.couponsList.concat(res.data.list);
  264. }
  265. that.mescroll.endBySize(res.data.list.length, res.data.total);
  266. }else{
  267. uni.showToast({
  268. icon:'none',
  269. title: "请求失败",
  270. });
  271. that.couponsList = null;
  272. that.mescroll.endErr();
  273. }
  274. // this.couponsList.push.apply(this.couponsList, res.data.list)
  275. // this.loadend = res.data.list.length < this.limit //判断所有数据是否加载完成;
  276. // this.page = this.page + 1
  277. })
  278. },
  279. },
  280. }
  281. </script>
  282. <style lang="less" scoped>
  283. .search-cont{
  284. padding: 16upx 30upx;
  285. background-color: #FFFFFF;
  286. .inner{
  287. box-sizing: border-box;
  288. width: 100%;
  289. height: 72upx;
  290. background: #F7F7F7;
  291. border-radius: 36upx;
  292. display: flex;
  293. align-items: center;
  294. padding: 0 30upx;
  295. .icon-search{
  296. width: 28upx;
  297. height: 28upx;
  298. margin-right: 20upx;
  299. }
  300. input{
  301. height: 60upx;
  302. line-height: 60upx;
  303. flex: 1;
  304. }
  305. }
  306. }
  307. .popbox{
  308. padding: 20rpx;
  309. height: 400rpx;
  310. .poplist{
  311. margin-top: 20rpx;
  312. .list-box{
  313. display: flex;
  314. justify-content: space-between;
  315. align-items: center;
  316. .tit{
  317. font-size:24rpx;
  318. color: #666;
  319. }
  320. .send{
  321. width: 122rpx;
  322. height: 50rpx;
  323. line-height: 50rpx;
  324. font-size: 26upx;
  325. font-family: PingFang SC;
  326. font-weight: 500;
  327. text-align: center;
  328. border-radius: 32upx;
  329. margin-left: 15upx;
  330. border: 1px solid #2BC7B9;
  331. color: #2BC7B9;
  332. }
  333. }
  334. }
  335. }
  336. .pop-tit{
  337. display: flex;
  338. padding: 20rpx;
  339. .poptitle{
  340. flex: 1;
  341. text-align: center;
  342. }
  343. }
  344. page {
  345. background-color: #f5f5f5;
  346. }
  347. .container {
  348. padding-bottom: env(safe-area-inset-bottom);
  349. }
  350. .top-fixed{
  351. width: 100%;
  352. position: fixed;
  353. top: 0;
  354. left: 0;
  355. z-index: 99999;
  356. .cate-list{
  357. box-sizing: border-box;
  358. background: #fff;
  359. padding: 10upx 27upx;
  360. height: 100upx;
  361. .inner{
  362. display: flex;
  363. }
  364. .item{
  365. flex-shrink: 0;
  366. padding: 0 24upx;
  367. height: 64upx;
  368. line-height: 64upx;
  369. font-size: 28upx;
  370. font-family: PingFang SC;
  371. font-weight: 500;
  372. color: #2BC7B9;
  373. background: #F5FFFE;
  374. border: 1px solid #8AD5CE;
  375. border-radius: 32upx;
  376. margin: 0 20upx 20upx 0;
  377. &.active{
  378. color: #FFFFFF;
  379. background: #2BC7B9;
  380. border: 1px solid #2BC7B9;
  381. }
  382. }
  383. }
  384. }
  385. .tui-coupon-list {
  386. margin-top: 120upx;
  387. width: 100%;
  388. padding: 0 25rpx;
  389. box-sizing: border-box;
  390. }
  391. .tui-coupon-banner {
  392. width: 100%;
  393. }
  394. .tui-coupon-item {
  395. width: 100%;
  396. height: 210rpx;
  397. position: relative;
  398. display: flex;
  399. align-items: center;
  400. padding-right: 30rpx;
  401. box-sizing: border-box;
  402. overflow: hidden;
  403. }
  404. .tui-coupon-bg {
  405. width: 100%;
  406. height: 210rpx;
  407. position: absolute;
  408. left: 0;
  409. top: 0;
  410. z-index: 1;
  411. }
  412. .tui-coupon-sign {
  413. height: 110rpx;
  414. width: 110rpx;
  415. position: absolute;
  416. z-index: 9;
  417. top: -30rpx;
  418. right: 40rpx;
  419. }
  420. .tui-coupon-item-left {
  421. width: 218rpx;
  422. height: 210rpx;
  423. position: relative;
  424. z-index: 2;
  425. display: flex;
  426. align-items: center;
  427. justify-content: center;
  428. flex-direction: column;
  429. flex-shrink: 0;
  430. }
  431. .tui-coupon-price-box {
  432. display: flex;
  433. color: #e41f19;
  434. align-items: flex-end;
  435. }
  436. .tui-coupon-price-sign {
  437. font-size: 30rpx;
  438. }
  439. .tui-coupon-price {
  440. font-size: 70rpx;
  441. line-height: 68rpx;
  442. font-weight: bold;
  443. }
  444. .tui-price-small {
  445. font-size: 58rpx !important;
  446. line-height: 56rpx !important;
  447. }
  448. .tui-coupon-intro {
  449. background: #f7f7f7;
  450. padding: 8rpx 10rpx;
  451. font-size: 26rpx;
  452. line-height: 26rpx;
  453. font-weight: 400;
  454. color: #666;
  455. margin-top: 18rpx;
  456. }
  457. .tui-coupon-item-right {
  458. flex: 1;
  459. height: 210rpx;
  460. position: relative;
  461. z-index: 2;
  462. display: flex;
  463. align-items: center;
  464. justify-content: space-between;
  465. padding-left: 24rpx;
  466. box-sizing: border-box;
  467. overflow: hidden;
  468. }
  469. .tui-coupon-content {
  470. width: 82%;
  471. display: flex;
  472. flex-direction: column;
  473. justify-content: center;
  474. }
  475. .tui-coupon-title-box {
  476. display: flex;
  477. align-items: center;
  478. }
  479. .tui-coupon-btn {
  480. padding: 6rpx;
  481. background: #ffebeb;
  482. color: #e41f19;
  483. font-size: 25rpx;
  484. line-height: 25rpx;
  485. display: flex;
  486. align-items: center;
  487. justify-content: center;
  488. transform: scale(0.9);
  489. transform-origin: 0 center;
  490. border-radius: 4rpx;
  491. flex-shrink: 0;
  492. }
  493. .tui-color-grey {
  494. color: #888 !important;
  495. }
  496. .tui-bg-grey {
  497. background: #f0f0f0 !important;
  498. color: #888 !important;
  499. }
  500. .tui-coupon-title {
  501. width: 100%;
  502. font-size: 26rpx;
  503. color: #333;
  504. white-space: nowrap;
  505. overflow: hidden;
  506. text-overflow: ellipsis;
  507. }
  508. .tui-coupon-rule {
  509. padding-top: 52rpx;
  510. }
  511. .tui-rule-box {
  512. display: flex;
  513. align-items: center;
  514. transform: scale(0.8);
  515. transform-origin: 0 100%;
  516. }
  517. .tui-padding-btm {
  518. padding-bottom: 6rpx;
  519. }
  520. .tui-coupon-circle {
  521. width: 8rpx;
  522. height: 8rpx;
  523. background: rgb(160, 160, 160);
  524. border-radius: 50%;
  525. }
  526. .tui-coupon-text {
  527. font-size: 28rpx;
  528. line-height: 28rpx;
  529. font-weight: 400;
  530. color: #666;
  531. padding-left: 8rpx;
  532. white-space: nowrap;
  533. }
  534. .tui-top20 {
  535. margin-top: 20rpx;
  536. }
  537. .tui-coupon-title {
  538. font-size: 28rpx;
  539. line-height: 28rpx;
  540. }
  541. .tui-coupon-radio {
  542. transform: scale(0.7);
  543. transform-origin: 100% center;
  544. }
  545. .tui-btn-box {
  546. position: absolute;
  547. right: 20rpx;
  548. bottom: 40rpx;
  549. z-index: 10;
  550. .btn{
  551. width: 155upx;
  552. height: 64upx;
  553. line-height: 64upx;
  554. font-size: 26upx;
  555. font-family: PingFang SC;
  556. font-weight: 500;
  557. text-align: center;
  558. border-radius: 32upx;
  559. margin-left: 15upx;
  560. &.cancel{
  561. border: 1px solid #2BC7B9;
  562. color: #2BC7B9;
  563. margin-bottom: 12rpx;
  564. }
  565. &.receive{
  566. background: #2BC7B9;
  567. color: #FFFFFF;
  568. }
  569. }
  570. }
  571. </style>