couponList.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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="baseUrl + '/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">{{ 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>
  53. </view>
  54. </view>
  55. </mescroll-body>
  56. </view>
  57. </template>
  58. <script>
  59. import {getDictByKey} from '@/api/common.js'
  60. import { getCouponList } from '@/api/coupon.js'
  61. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  62. export default {
  63. name: 'UserCoupon',
  64. props: {},
  65. mixins: [MescrollMixin], // 使用mixin
  66. data: function() {
  67. return {
  68. baseUrl:uni.getStorageSync('requestPath'),
  69. keyword: '',
  70. cateOptions:[],
  71. cateId:null,
  72. couponType:null,
  73. mescroll:null,
  74. downOption: { //下拉刷新
  75. use:true,
  76. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  77. },
  78. upOption: {
  79. onScroll:false,
  80. use: true, // 是否启用上拉加载; 默认true
  81. page: {
  82. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  83. size: 10 // 每页数据的数量,默认10
  84. },
  85. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  86. textNoMore:"已经到底了",
  87. empty: {
  88. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  89. tip: '暂无数据'
  90. }
  91. },
  92. dataList: [],
  93. isShare:null,
  94. }
  95. },
  96. watch: {
  97. },
  98. onLoad(options) {
  99. this.couponType=options.couponType;
  100. this.isShare=options.isShare;
  101. },
  102. onShow() {
  103. if(this.couponType==5){
  104. this.getDictByKey("sys_package_private_type");
  105. }
  106. else if(this.couponType==6){
  107. this.getDictByKey("sys_package_disease_type");
  108. }
  109. },
  110. methods: {
  111. choseCate(item) {
  112. this.cateId = item.dictValue;
  113. this.mescroll.resetUpScroll()
  114. },
  115. getDictByKey(key){
  116. var data={key:key}
  117. getDictByKey(data).then(
  118. res => {
  119. if(res.code==200){
  120. this.cateOptions=res.data;
  121. }
  122. },
  123. err => {
  124. }
  125. );
  126. },
  127. doSearch(){
  128. this.mescroll.resetUpScroll()
  129. },
  130. navTo(url){
  131. uni.navigateTo({
  132. url: url
  133. })
  134. },
  135. mescrollInit(mescroll) {
  136. this.mescroll = mescroll;
  137. },
  138. /*下拉刷新的回调 */
  139. downCallback() {
  140. this.mescroll.resetUpScroll()
  141. },
  142. /*上拉加载的回调*/
  143. upCallback(page) {
  144. //联网加载数据
  145. var that = this;
  146. var data = {
  147. keyword:this.keyword,
  148. couponType:this.couponType,
  149. pageNum: page.num,
  150. pageSize: page.size
  151. };
  152. if(this.cateId!=null){
  153. data.cateId=this.cateId;
  154. }
  155. getCouponList(data).then(res => {
  156. if(res.code==200){
  157. if (page.num == 1) {
  158. that.dataList = res.data.list;
  159. } else {
  160. that.dataList = that.dataList.concat(res.data.list);
  161. }
  162. that.mescroll.endBySize(res.data.list.length, res.data.total);
  163. }else{
  164. uni.showToast({
  165. icon:'none',
  166. title: "请求失败",
  167. });
  168. that.dataList = null;
  169. that.mescroll.endErr();
  170. }
  171. });
  172. },
  173. },
  174. }
  175. </script>
  176. <style lang="less" scoped>
  177. .content{
  178. height: 100%;
  179. .top-content{
  180. width: 100%;
  181. position: fixed;
  182. top: 0;
  183. left: 0;
  184. z-index: 10;
  185. }
  186. .search-cont{
  187. padding: 16upx 30upx;
  188. background-color: #FFFFFF;
  189. .inner{
  190. box-sizing: border-box;
  191. width: 100%;
  192. height: 72upx;
  193. background: #F7F7F7;
  194. border-radius: 36upx;
  195. display: flex;
  196. align-items: center;
  197. padding: 0 30upx;
  198. .icon-search{
  199. width: 28upx;
  200. height: 28upx;
  201. margin-right: 20upx;
  202. }
  203. input{
  204. height: 60upx;
  205. line-height: 60upx;
  206. flex: 1;
  207. }
  208. }
  209. }
  210. .cate-list{
  211. box-sizing: border-box;
  212. background: #fff;
  213. padding: 10upx 27upx;
  214. height: 100upx;
  215. .inner{
  216. display: flex;
  217. }
  218. .item{
  219. flex-shrink: 0;
  220. padding: 0 24upx;
  221. height: 64upx;
  222. line-height: 64upx;
  223. font-size: 28upx;
  224. font-family: PingFang SC;
  225. font-weight: 500;
  226. color: #C39A58;
  227. background: #ffffff;
  228. border: 1px solid #E2C99E;
  229. border-radius: 32upx;
  230. margin: 0 20upx 20upx 0;
  231. &.active{
  232. color: #FFFFFF;
  233. background: #C39A58;
  234. border: 1px solid #C39A58;
  235. }
  236. }
  237. }
  238. }
  239. .tui-coupon-list {
  240. margin-top: 0upx;
  241. width: 100%;
  242. padding: 0 25rpx;
  243. box-sizing: border-box;
  244. }
  245. .tui-coupon-banner {
  246. width: 100%;
  247. }
  248. .tui-coupon-item {
  249. width: 100%;
  250. height: 210rpx;
  251. position: relative;
  252. display: flex;
  253. align-items: center;
  254. padding-right: 30rpx;
  255. box-sizing: border-box;
  256. overflow: hidden;
  257. }
  258. .tui-coupon-bg {
  259. width: 100%;
  260. height: 210rpx;
  261. position: absolute;
  262. left: 0;
  263. top: 0;
  264. z-index: 1;
  265. }
  266. .tui-coupon-sign {
  267. height: 110rpx;
  268. width: 110rpx;
  269. position: absolute;
  270. z-index: 9;
  271. top: -30rpx;
  272. right: 40rpx;
  273. }
  274. .tui-coupon-item-left {
  275. width: 218rpx;
  276. height: 210rpx;
  277. position: relative;
  278. z-index: 2;
  279. display: flex;
  280. align-items: center;
  281. justify-content: center;
  282. flex-direction: column;
  283. flex-shrink: 0;
  284. }
  285. .tui-coupon-price-box {
  286. display: flex;
  287. color: #e41f19;
  288. align-items: flex-end;
  289. }
  290. .tui-coupon-price-sign {
  291. font-size: 30rpx;
  292. }
  293. .tui-coupon-price {
  294. font-size: 32rpx;
  295. line-height: 68rpx;
  296. font-weight: bold;
  297. }
  298. .tui-price-small {
  299. font-size: 58rpx !important;
  300. line-height: 56rpx !important;
  301. }
  302. .tui-coupon-intro {
  303. background: #f7f7f7;
  304. padding: 8rpx 10rpx;
  305. font-size: 26rpx;
  306. line-height: 26rpx;
  307. font-weight: 400;
  308. color: #666;
  309. margin-top: 18rpx;
  310. }
  311. .tui-coupon-item-right {
  312. flex: 1;
  313. height: 210rpx;
  314. position: relative;
  315. z-index: 2;
  316. display: flex;
  317. align-items: center;
  318. justify-content: space-between;
  319. padding-left: 24rpx;
  320. box-sizing: border-box;
  321. overflow: hidden;
  322. }
  323. .tui-coupon-content {
  324. width: 82%;
  325. display: flex;
  326. flex-direction: column;
  327. justify-content: center;
  328. }
  329. .tui-coupon-title-box {
  330. display: flex;
  331. align-items: center;
  332. }
  333. .tui-coupon-btn {
  334. padding: 6rpx;
  335. background: #ffebeb;
  336. color: #C39A58;
  337. font-size: 25rpx;
  338. line-height: 25rpx;
  339. display: flex;
  340. align-items: center;
  341. justify-content: center;
  342. transform: scale(0.9);
  343. transform-origin: 0 center;
  344. border-radius: 4rpx;
  345. flex-shrink: 0;
  346. }
  347. .tui-color-grey {
  348. color: #888 !important;
  349. }
  350. .tui-bg-grey {
  351. background: #f0f0f0 !important;
  352. color: #888 !important;
  353. }
  354. .tui-coupon-title {
  355. width: 100%;
  356. font-size: 26rpx;
  357. color: #333;
  358. white-space: nowrap;
  359. overflow: hidden;
  360. text-overflow: ellipsis;
  361. }
  362. .tui-coupon-rule {
  363. padding-top: 52rpx;
  364. }
  365. .tui-rule-box {
  366. display: flex;
  367. align-items: center;
  368. transform: scale(0.8);
  369. transform-origin: 0 100%;
  370. }
  371. .tui-padding-btm {
  372. padding-bottom: 6rpx;
  373. }
  374. .tui-coupon-circle {
  375. width: 8rpx;
  376. height: 8rpx;
  377. background: rgb(160, 160, 160);
  378. border-radius: 50%;
  379. }
  380. .tui-coupon-text {
  381. font-size: 28rpx;
  382. line-height: 28rpx;
  383. font-weight: 400;
  384. color: #666;
  385. padding-left: 8rpx;
  386. white-space: nowrap;
  387. }
  388. .tui-top20 {
  389. margin-top: 20rpx;
  390. }
  391. .tui-coupon-title {
  392. font-size: 28rpx;
  393. line-height: 28rpx;
  394. }
  395. .tui-coupon-radio {
  396. transform: scale(0.7);
  397. transform-origin: 100% center;
  398. }
  399. .tui-btn-box {
  400. position: absolute;
  401. right: 20rpx;
  402. bottom: 40rpx;
  403. z-index: 10;
  404. .btn{
  405. width: 155upx;
  406. height: 64upx;
  407. line-height: 64upx;
  408. font-size: 26upx;
  409. font-family: PingFang SC;
  410. font-weight: 500;
  411. text-align: center;
  412. border-radius: 32upx;
  413. margin-left: 15upx;
  414. &.cancel{
  415. border: 1px solid red;
  416. color: red;
  417. }
  418. &.receive{
  419. background: #C39A58;
  420. color: #FFFFFF;
  421. }
  422. }
  423. }
  424. </style>