couponList.vue 9.7 KB

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