coupon.vue 11 KB

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