couponList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view class="content">
  3. <view class="top-content" v-if="couponType==5||couponType==6">
  4. <!-- 搜索框 -->
  5. <view class="search-cont">
  6. <view class="inner">
  7. <image class="icon-search" src="/static/images/icon_search.png" mode=""></image>
  8. <input type="text" v-model="keyword" placeholder="输入名称搜索" confirm-type="search" @confirm="doSearch" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  9. </view>
  10. </view>
  11. <view class="cate-list">
  12. <!-- 关键字列表 -->
  13. <scroll-view scroll-x="true" >
  14. <view class="inner">
  15. <view v-for="(item,index) in cateOptions" :key="index" :class="cateId == item.dictValue?'item active':'item'" @click="choseCate(item)">
  16. {{ item.dictLabel }}
  17. </view>
  18. </view>
  19. </scroll-view>
  20. </view>
  21. </view>
  22. <mescroll-body :top="couponType==5||couponType==6?'192rpx':'0rpx'" bottom="0" ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
  23. <view class="tui-coupon-list">
  24. <view class="tui-coupon-item tui-top20" v-for="(item, index) in dataList" :key="index">
  25. <image src="/static/images/bg_coupon_3x.png" class="tui-coupon-bg" mode="widthFix"></image>
  26. <view class="tui-coupon-item-left">
  27. <view class="tui-coupon-price-box" >
  28. <view class="tui-coupon-price-sign">¥</view>
  29. <view class="tui-coupon-price" :class="{ 'tui-price-small': false }">{{ item.price.toFixed(2) }}</view>
  30. </view>
  31. <view class="tui-coupon-intro">满{{ item.minPrice.toFixed(2) }}元可用</view>
  32. </view>
  33. <view class="tui-coupon-item-right">
  34. <view class="tui-coupon-content">
  35. <view class="tui-coupon-title-box">
  36. <view class="tui-coupon-title ellipsis2">{{ item.title }}</view>
  37. </view>
  38. <view class="tui-coupon-rule">
  39. <view class="tui-rule-box tui-padding-btm">
  40. <view class="tui-coupon-circle"></view>
  41. <view class="tui-coupon-text">不可叠加使用</view>
  42. </view>
  43. <view class="tui-rule-box">
  44. <view class="tui-coupon-circle"></view>
  45. <view class="tui-coupon-text">{{ item.limitTime }} 到期</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="tui-btn-box">
  51. <view class="btn receive" @click="navTo('/pages/company/couponDetails?isShare='+isShare+'&couponId='+item.couponId)">查看</view>
  52. <view class="btn share" @click.stop="genCode(item)">分享</view>
  53. </view>
  54. </view>
  55. </view>
  56. </mescroll-body>
  57. <!-- 分享弹窗 -->
  58. <u-popup :show="showShare" @close="showShare = false" >
  59. <share-box :shareItem="shareItem" @closeShare='showShare = false' ></share-box>
  60. </u-popup>
  61. </view>
  62. </template>
  63. <script>
  64. import {getDictByKey} from '@/api/common.js'
  65. import { getCouponList,genCode } from '@/api/coupon.js'
  66. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  67. export default {
  68. name: 'UserCoupon',
  69. props: {},
  70. mixins: [MescrollMixin], // 使用mixin
  71. data: function() {
  72. return {
  73. keyword: '',
  74. cateOptions:[],
  75. cateId:null,
  76. couponType:null,
  77. mescroll:null,
  78. downOption: { //下拉刷新
  79. use:true,
  80. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  81. },
  82. upOption: {
  83. onScroll:false,
  84. use: true, // 是否启用上拉加载; 默认true
  85. page: {
  86. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  87. size: 10 // 每页数据的数量,默认10
  88. },
  89. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  90. textNoMore:"已经到底了",
  91. empty: {
  92. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  93. tip: '暂无数据'
  94. }
  95. },
  96. dataList: [],
  97. isShare:null,
  98. isH5:false,
  99. showShare:false,
  100. shareItem:{ imageUrl:"",title:"",path:"",isMini:true },
  101. companyId:null,
  102. companyUserId:null,
  103. code:"",
  104. }
  105. },
  106. watch: {
  107. },
  108. onLoad(options) {
  109. this.couponType=options.couponType;
  110. this.isShare=options.isShare;
  111. this.companyId=uni.getStorageSync('companyId');
  112. this.companyUserId=uni.getStorageSync('companyUserId');
  113. //#ifdef H5
  114. this.isH5=true;
  115. //#endif
  116. },
  117. onShow() {
  118. if(this.couponType==5){
  119. this.getDictByKey("sys_package_private_type");
  120. }
  121. else if(this.couponType==6){
  122. this.getDictByKey("sys_package_disease_type");
  123. }
  124. },
  125. methods: {
  126. choseCate(item) {
  127. this.cateId = item.dictValue;
  128. this.mescroll.resetUpScroll()
  129. },
  130. getDictByKey(key){
  131. var data={key:key}
  132. getDictByKey(data).then(
  133. res => {
  134. if(res.code==200){
  135. this.cateOptions=res.data;
  136. }
  137. },
  138. err => {
  139. }
  140. );
  141. },
  142. doSearch(){
  143. this.mescroll.resetUpScroll()
  144. },
  145. navTo(url){
  146. uni.navigateTo({
  147. url: url
  148. })
  149. },
  150. mescrollInit(mescroll) {
  151. this.mescroll = mescroll;
  152. },
  153. /*下拉刷新的回调 */
  154. downCallback() {
  155. this.mescroll.resetUpScroll()
  156. },
  157. /*上拉加载的回调*/
  158. upCallback(page) {
  159. //联网加载数据
  160. var that = this;
  161. var data = {
  162. keyword:this.keyword,
  163. couponType:this.couponType,
  164. pageNum: page.num,
  165. pageSize: page.size
  166. };
  167. if(this.cateId!=null){
  168. data.cateId=this.cateId;
  169. }
  170. getCouponList(data).then(res => {
  171. if(res.code==200){
  172. if (page.num == 1) {
  173. that.dataList = res.data.list;
  174. } else {
  175. that.dataList = that.dataList.concat(res.data.list);
  176. }
  177. that.mescroll.endBySize(res.data.list.length, res.data.total);
  178. }
  179. else{
  180. uni.showToast({
  181. icon:'none',
  182. title: "请求失败",
  183. });
  184. that.dataList = null;
  185. that.mescroll.endErr();
  186. }
  187. });
  188. },
  189. genCode: function(item) {
  190. let that = this
  191. var data={"couponId":item.couponId};
  192. genCode(data)
  193. .then(function(res) {
  194. that.code=res.data;
  195. that.doShare(item);
  196. })
  197. .catch(function(err) {
  198. })
  199. },
  200. doShare(item){
  201. if(this.isH5){
  202. return;
  203. }
  204. this.shareItem.title=item.title;
  205. this.shareItem.imageUrl="../../static/image/my/coupon_bg.png";
  206. this.shareItem.isMini=true;
  207. this.shareItem.path="/pages_company/couponDetails?couponId="+item.couponId+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&code="+this.code;
  208. console.log("qxj path:"+this.shareItem.path);
  209. let cdn=uni.getStorageSync('h5Path');
  210. this.shareItem.url=cdn+"/pages/company/couponDetails?couponId="+item.couponId+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&code="+this.code;
  211. this.showShare=true;
  212. }
  213. },
  214. }
  215. </script>
  216. <style lang="less" scoped>
  217. .content{
  218. height: 100%;
  219. .top-content{
  220. width: 100%;
  221. position: absolute;
  222. top: 0;
  223. left: 0;
  224. z-index: 10;
  225. }
  226. .search-cont{
  227. padding: 16upx 30upx;
  228. background-color: #FFFFFF;
  229. .inner{
  230. box-sizing: border-box;
  231. width: 100%;
  232. height: 72upx;
  233. background: #F7F7F7;
  234. border-radius: 36upx;
  235. display: flex;
  236. align-items: center;
  237. padding: 0 30upx;
  238. .icon-search{
  239. width: 28upx;
  240. height: 28upx;
  241. margin-right: 20upx;
  242. }
  243. input{
  244. height: 60upx;
  245. line-height: 60upx;
  246. flex: 1;
  247. }
  248. }
  249. }
  250. .cate-list{
  251. box-sizing: border-box;
  252. background: #fff;
  253. padding: 10upx 27upx;
  254. height: 100upx;
  255. .inner{
  256. display: flex;
  257. }
  258. .item{
  259. background-color: #fff;
  260. flex-shrink: 0;
  261. padding: 0 24upx;
  262. height: 64upx;
  263. line-height: 64upx;
  264. font-size: 28upx;
  265. font-family: PingFang SC;
  266. font-weight: 500;
  267. color: #FF5C03;
  268. border: 1px solid #E2C99E;
  269. border-radius: 32upx;
  270. margin: 0 20upx 20upx 0;
  271. &.active{
  272. color: #FFFFFF;
  273. background: #FF5C03;
  274. border: 1px solid #FF5C03;
  275. }
  276. }
  277. }
  278. }
  279. .tui-coupon-list {
  280. margin-top: 0upx;
  281. width: 100%;
  282. padding: 0 25rpx;
  283. box-sizing: border-box;
  284. }
  285. .tui-coupon-banner {
  286. width: 100%;
  287. }
  288. .tui-coupon-item {
  289. background-color: #fff;
  290. width: 100%;
  291. height: 210rpx;
  292. position: relative;
  293. display: flex;
  294. align-items: center;
  295. padding-right: 30rpx;
  296. box-sizing: border-box;
  297. overflow: hidden;
  298. }
  299. .tui-coupon-bg {
  300. width: 100%;
  301. height: 210rpx;
  302. position: absolute;
  303. left: 0;
  304. top: 0;
  305. z-index: 1;
  306. }
  307. .tui-coupon-sign {
  308. height: 110rpx;
  309. width: 110rpx;
  310. position: absolute;
  311. z-index: 9;
  312. top: -30rpx;
  313. right: 40rpx;
  314. }
  315. .tui-coupon-item-left {
  316. width: 218rpx;
  317. height: 210rpx;
  318. position: relative;
  319. z-index: 2;
  320. display: flex;
  321. align-items: center;
  322. justify-content: center;
  323. flex-direction: column;
  324. flex-shrink: 0;
  325. }
  326. .tui-coupon-price-box {
  327. display: flex;
  328. color: #e41f19;
  329. align-items: flex-end;
  330. }
  331. .tui-coupon-price-sign {
  332. font-size: 30rpx;
  333. }
  334. .tui-coupon-price {
  335. font-size: 32rpx;
  336. line-height: 68rpx;
  337. font-weight: bold;
  338. }
  339. .tui-price-small {
  340. font-size: 58rpx !important;
  341. line-height: 56rpx !important;
  342. }
  343. .tui-coupon-intro {
  344. background: #f7f7f7;
  345. padding: 8rpx 10rpx;
  346. font-size: 26rpx;
  347. line-height: 26rpx;
  348. font-weight: 400;
  349. color: #666;
  350. margin-top: 18rpx;
  351. }
  352. .tui-coupon-item-right {
  353. flex: 1;
  354. height: 210rpx;
  355. position: relative;
  356. z-index: 2;
  357. display: flex;
  358. align-items: center;
  359. justify-content: space-between;
  360. padding-left: 24rpx;
  361. box-sizing: border-box;
  362. overflow: hidden;
  363. }
  364. .tui-coupon-content {
  365. width: 82%;
  366. display: flex;
  367. flex-direction: column;
  368. justify-content: center;
  369. }
  370. .tui-coupon-title-box {
  371. display: flex;
  372. align-items: center;
  373. }
  374. .tui-coupon-btn {
  375. padding: 6rpx;
  376. background: #ffebeb;
  377. color: #FF5C03;
  378. font-size: 25rpx;
  379. line-height: 25rpx;
  380. display: flex;
  381. align-items: center;
  382. justify-content: center;
  383. transform: scale(0.9);
  384. transform-origin: 0 center;
  385. border-radius: 4rpx;
  386. flex-shrink: 0;
  387. }
  388. .tui-color-grey {
  389. color: #888 !important;
  390. }
  391. .tui-bg-grey {
  392. background: #f0f0f0 !important;
  393. color: #888 !important;
  394. }
  395. .tui-coupon-title {
  396. width: 100%;
  397. font-size: 26rpx;
  398. color: #333;
  399. white-space: nowrap;
  400. overflow: hidden;
  401. text-overflow: ellipsis;
  402. }
  403. .tui-coupon-rule {
  404. padding-top: 52rpx;
  405. }
  406. .tui-rule-box {
  407. display: flex;
  408. align-items: center;
  409. transform: scale(0.8);
  410. transform-origin: 0 100%;
  411. }
  412. .tui-padding-btm {
  413. padding-bottom: 6rpx;
  414. }
  415. .tui-coupon-circle {
  416. width: 8rpx;
  417. height: 8rpx;
  418. background: rgb(160, 160, 160);
  419. border-radius: 50%;
  420. }
  421. .tui-coupon-text {
  422. font-size: 28rpx;
  423. line-height: 28rpx;
  424. font-weight: 400;
  425. color: #666;
  426. padding-left: 8rpx;
  427. white-space: nowrap;
  428. }
  429. .tui-top20 {
  430. margin-top: 20rpx;
  431. }
  432. .tui-coupon-title {
  433. font-size: 28rpx;
  434. line-height: 28rpx;
  435. }
  436. .tui-coupon-radio {
  437. transform: scale(0.7);
  438. transform-origin: 100% center;
  439. }
  440. .tui-btn-box {
  441. position: absolute;
  442. right: 20rpx;
  443. bottom: 40rpx;
  444. z-index: 10;
  445. .btn{
  446. width: 120upx;
  447. height: 64upx;
  448. line-height: 64upx;
  449. font-size: 26upx;
  450. font-family: PingFang SC;
  451. font-weight: 500;
  452. text-align: center;
  453. border-radius: 32upx;
  454. margin-left: 15upx;
  455. &.cancel{
  456. border: 1px solid red;
  457. color: red;
  458. }
  459. &.receive{
  460. background: #FF5C03;
  461. color: #FFFFFF;
  462. }
  463. &.share{
  464. background: #2BC7B9;
  465. color: #FFFFFF;
  466. margin-top: 10rpx;
  467. }
  468. }
  469. }
  470. </style>