coupon.vue 13 KB

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