当前位置:   article > 正文

微信小程序 简单优惠卷页面设计_微信小程序优惠券页面的实现

微信小程序优惠券页面的实现

index.wxml

  1. <view style="margin: 0.5rem;">
  2. <view class="points">
  3. 我的积分:{{integralInfo}}
  4. </view>
  5. </view>
  6. <view>
  7. <view wx:if="{{couponList.length>0}}" wx:for="{{couponList}}" wx:key="{{item.id}}">
  8. <view class="tickets">
  9. <view class="l-tickets.usable">
  10. <view class="discounts">
  11. <text class="symbol"></text>
  12. <text class="quantity">{{item.couponValue}}</text>
  13. </view>
  14. <view class="rule">
  15. <text class="rule-text">{{item.useSill}}</text>
  16. </view>
  17. </view>
  18. <view class="r-tickets">
  19. <van-row>
  20. <van-col span="22">
  21. <view class="coupon-left">
  22. <view class="coupon-name">
  23. <text class="coupon-name-text {{currentTab ==0 ? 'usable' : currentTab ==1 ? 'used' : 'expired'}}">{{item.couponName}}</text>
  24. </view>
  25. <view class="coupon-Instructions">
  26. <text class="coupon-Instructions-text {{currentTab ==0 ? 'usable' : currentTab ==1 ? 'used' : 'expired'}}">{{item.couponExplain}}</text>
  27. </view>
  28. <view class="coupon-validity">
  29. <text class="coupon-validity-text {{currentTab ==0 ? 'usable' : currentTab ==1 ? 'used' : 'expired'}}">有效日期:{{item.deadlineDate}}</text>
  30. </view>
  31. </view>
  32. </van-col>
  33. <van-col span="2">
  34. <view bindtap="exchangeCoupon" data-info="{{item}}" class="lmmediate-use.usable">
  35. 立即兑换
  36. </view>
  37. </van-col>
  38. </van-row>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="empty" wx:if="{{couponList.length==0}}">
  43. <van-empty description="暂无优惠卷!" />
  44. <!-- <van-empty class="custom-image" image="/pages/image/userCenter/coupon.png" description="暂无优惠卷!" /> -->
  45. </view>
  46. </view>
  47. <van-dialog style="text-align: center;" use-slot title="{{popupData.codename}}" show="{{ show }}" bind:close="onClose">
  48. <image style="width: 15rem;height: 15rem;" src="{{popupData.codeimage}}" />
  49. <view style="text-align: center;font-size: 0.95rem;font-weight: 700;margin-bottom: 0.5rem;letter-spacing: 0.05rem;margin-top: -1rem;">
  50. {{popupData.code}}
  51. </view>
  52. </van-dialog>

index.wxss

  1. .topBar {
  2. margin-top: -0.5rem;
  3. display: flex;
  4. /* box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.5); */
  5. /* position: fixed; */
  6. top: 0;
  7. left: 0;
  8. width: 100%;
  9. z-index: 9999;
  10. background-color: white;
  11. }
  12. .classScroll {
  13. width: 375px;
  14. padding-left: 2px;
  15. }
  16. .tab-bar {
  17. display: flex;
  18. justify-content: flex-start;
  19. /* 修改为左对齐 */
  20. width: fit-content;
  21. /* 修改为适应内容的宽度 */
  22. }
  23. .tab-item {
  24. flex: 1 0 auto;
  25. display: inline-flex;
  26. flex-direction: column;
  27. align-items: center;
  28. justify-content: center;
  29. padding-left: 5px;
  30. padding-right: 5px;
  31. line-height: 40px;
  32. color: #888888;
  33. }
  34. .tab-item.active {
  35. /* margin-left: 0.5rem; */
  36. height: 1.5rem;
  37. width: 3rem;
  38. color: black;
  39. border-radius: 5px;
  40. font-weight: 500;
  41. font-weight: bolder;
  42. }
  43. .tab-item.index {
  44. /* margin-left: 0.5rem; */
  45. height: 1.5rem;
  46. width: 3rem;
  47. color: rgb(156, 148, 148);
  48. border-radius: 5px;
  49. font-weight: bolder;
  50. }
  51. .teacher .tab-item.active1 {
  52. /* margin-left: 0.5rem; */
  53. height: 1.5rem;
  54. width: 2rem;
  55. color: #56c5a1;
  56. /* border-radius: 5px; */
  57. /* background-color: #56c5a1; */
  58. font-weight: bolder;
  59. }
  60. .text-title.active1 {
  61. height: 2rem;
  62. border-bottom-color: #56c5a1;
  63. border-bottom-style: solid;
  64. border-bottom-width: 6rpx;
  65. }
  66. .points {
  67. font-size: 0.95rem;
  68. font-weight: 800;
  69. }
  70. .convert {
  71. font-size: 0.65rem;
  72. float: right;
  73. margin-right: 0.5rem;
  74. margin-top: 0.5rem;
  75. background-color: #2ea37e;
  76. color: white;
  77. padding: 0.25rem 0.25rem;
  78. border-radius: 5px;
  79. font-weight: bolder;
  80. letter-spacing: 0.15rem;
  81. }
  82. .tickets {
  83. display: flex;
  84. padding: 20rpx;
  85. width: 100%;
  86. height: 230rpx;
  87. box-sizing: border-box;
  88. }
  89. .l-tickets.usable {
  90. width: 25%;
  91. position: relative;
  92. background: radial-gradient(circle at right top, transparent 16rpx, #ce0f0f 0, #c9380c 100%) right top / 100% 50% no-repeat,
  93. radial-gradient(circle at right bottom, transparent 16rpx, #ce0f0f 0, #c9380c 100%) right bottom / 100% 50% no-repeat;
  94. filter: drop-shadow(-3px 0 3px rgba(0, 0, 0, .3));
  95. }
  96. .l-tickets.usable::after {
  97. content: '';
  98. position: absolute;
  99. height: 100%;
  100. width: 8rpx;
  101. top: 0;
  102. left: -8rpx;
  103. background: radial-gradient(circle at left center, transparent 8rpx, #ce0f0f 0) left center / 8rpx 20rpx;
  104. }
  105. .l-tickets.used {
  106. width: 25%;
  107. position: relative;
  108. background: radial-gradient(circle at right top, transparent 16rpx, #835243 0, #ac644e 100%) right top / 100% 50% no-repeat,
  109. radial-gradient(circle at right bottom, transparent 16rpx, #835243 0, #ac644e 100%) right bottom / 100% 50% no-repeat;
  110. filter: drop-shadow(-3px 0 3px rgba(0, 0, 0, .3));
  111. }
  112. .l-tickets.used::after {
  113. content: '';
  114. position: absolute;
  115. height: 100%;
  116. width: 8rpx;
  117. top: 0;
  118. left: -8rpx;
  119. background: radial-gradient(circle at left center, transparent 8rpx, #ac644e 0) left center / 8rpx 20rpx;
  120. }
  121. .l-tickets.expired {
  122. width: 25%;
  123. position: relative;
  124. background: radial-gradient(circle at right top, transparent 16rpx, #999292 0, #817a7a 100%) right top / 100% 50% no-repeat,
  125. radial-gradient(circle at right bottom, transparent 16rpx, #999292 0, #817a7a 100%) right bottom / 100% 50% no-repeat;
  126. filter: drop-shadow(-3px 0 3px rgba(0, 0, 0, .3));
  127. }
  128. .l-tickets.expired::after {
  129. content: '';
  130. position: absolute;
  131. height: 100%;
  132. width: 8rpx;
  133. top: 0;
  134. left: -8rpx;
  135. background: radial-gradient(circle at left center, transparent 8rpx, #817a7a 0) left center / 8rpx 20rpx;
  136. }
  137. .r-tickets {
  138. flex: 1;
  139. position: relative;
  140. background: radial-gradient(circle at left top, transparent 16rpx, #fdfcfb 0, #fdfcfb 100%) right top / 100% 50% no-repeat,
  141. radial-gradient(circle at left bottom, transparent 16rpx, #fdfcfb 0, #fdfcfb 100%) right bottom / 100% 50% no-repeat;
  142. filter: drop-shadow(3px 0 3px rgba(0, 0, 0, .3));
  143. }
  144. .r-tickets::before {
  145. content: '';
  146. width: 1rpx;
  147. background: linear-gradient(to top, #fff 0%, #fff 50%, transparent 50%) top left / 1rpx 20rpx repeat-y;
  148. position: absolute;
  149. left: 0;
  150. top: 16rpx;
  151. bottom: 16rpx;
  152. }
  153. .r-tickets::after {
  154. content: '';
  155. position: absolute;
  156. height: 100%;
  157. width: 8rpx;
  158. top: 0;
  159. right: -8rpx;
  160. background: radial-gradient(circle at right center, transparent 8rpx, #fdfcfb 0) right center / 8rpx 20rpx;
  161. }
  162. .discounts {
  163. color: white;
  164. text-align: center;
  165. margin-top: 1.0rem;
  166. }
  167. .symbol {
  168. font-size: 1.25rem;
  169. }
  170. .quantity {
  171. font-size: 1.75rem;
  172. }
  173. .rule {
  174. margin-top: 0.5rem;
  175. text-align: center;
  176. color: white;
  177. }
  178. .rule-text {
  179. font-size: 0.65rem;
  180. }
  181. .coupon-left {
  182. /* width: 100%; */
  183. /* height: 190rpx; */
  184. margin-left: 20rpx;
  185. padding-right: 10rpx;
  186. border-right-color: #79726f;
  187. border-right-style: solid;
  188. border-right-width: 2rpx;
  189. border-right-style: dashed;
  190. }
  191. .coupon-name {
  192. margin-top: 10rpx;
  193. font-weight: 1000;
  194. display: -webkit-box;
  195. -webkit-box-orient: vertical;
  196. -webkit-line-clamp: 1;
  197. overflow: hidden;
  198. text-overflow: ellipsis;
  199. }
  200. .coupon-Instructions {
  201. margin-top: 0.5rem;
  202. height: 70rpx;
  203. display: -webkit-box;
  204. -webkit-box-orient: vertical;
  205. -webkit-line-clamp: 3;
  206. overflow: hidden;
  207. text-overflow: ellipsis;
  208. }
  209. .coupon-validity {
  210. margin-top: 0.5rem;
  211. }
  212. /* 立即使用 */
  213. .coupon-name-text.usable {
  214. font-size: 0.85rem;
  215. color: black;
  216. }
  217. .coupon-Instructions-text.usable {
  218. font-size: 0.80rem;
  219. color: black;
  220. }
  221. .coupon-validity-text.usable {
  222. font-size: 0.80rem;
  223. color: rgb(90, 81, 81);
  224. }
  225. /* 已使用 */
  226. .coupon-name-text.used {
  227. font-size: 0.85rem;
  228. color: #ac644e;
  229. }
  230. .coupon-Instructions-text.used {
  231. font-size: 0.80rem;
  232. color: #ac644e;
  233. }
  234. .coupon-validity-text.used {
  235. font-size: 0.80rem;
  236. color: #ac644e;
  237. }
  238. /* 已过期 */
  239. .coupon-name-text.expired {
  240. font-size: 0.85rem;
  241. color: #817a7a;
  242. }
  243. .coupon-Instructions-text.expired {
  244. font-size: 0.80rem;
  245. color: #817a7a;
  246. }
  247. .coupon-validity-text.expired {
  248. font-size: 0.80rem;
  249. color: #817a7a;
  250. }
  251. .lmmediate-use.usable {
  252. color: tomato;
  253. margin-top: 20rpx;
  254. display: flex;
  255. text-align: center;
  256. justify-content: center;
  257. }
  258. .lmmediate-use.used {
  259. color: #ac644e;
  260. margin-top: 35rpx;
  261. display: flex;
  262. text-align: center;
  263. justify-content: center;
  264. }
  265. .lmmediate-use.expired {
  266. color: #817a7a;
  267. margin-top: 35rpx;
  268. display: flex;
  269. text-align: center;
  270. justify-content: center;
  271. }
  272. /* .empty .van-empty__image__img {
  273. height: 8rem;
  274. width: 8rem;
  275. } */
  276. /* .empty .van-empty__description {
  277. color: #969799;
  278. font-size: 20px;
  279. line-height: 20px;
  280. margin-top: 16px;
  281. padding: 0 60px;
  282. } */

index.js

  1. // pages/user/pointExchange/pointExchange.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. currentTab: 0,
  8. show: false,
  9. integralInfo:0,
  10. couponList: [{
  11. ids: 0,
  12. couponValue: 299,
  13. useSill: "满6500元可用",
  14. couponName: "手机回收平台加价卷",
  15. couponExplain: "用户回收手机可使用此卷",
  16. deadlineDate: "兑换起1月内",
  17. timeLimit: 1,
  18. },
  19. {
  20. ids: 1,
  21. couponValue: 129,
  22. useSill: "无使用门槛",
  23. couponName: "笔记本回收平台加价卷",
  24. couponExplain: "用户回收笔记本可使用此卷",
  25. deadlineDate: "兑换起3个月内",
  26. timeLimit:3
  27. },
  28. ]
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad(options) {
  34. // this.getMyIntegralInfo()
  35. },
  36. exchangeCoupon(e){
  37. var that=this
  38. console.log("====",e.currentTarget.dataset.info)
  39. return
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady() {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow() {
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide() {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload() {
  60. },
  61. /**
  62. * 页面相关事件处理函数--监听用户下拉动作
  63. */
  64. onPullDownRefresh() {
  65. },
  66. /**
  67. * 页面上拉触底事件的处理函数
  68. */
  69. onReachBottom() {
  70. },
  71. /**
  72. * 用户点击右上角分享
  73. */
  74. onShareAppMessage() {
  75. }
  76. })

页面效果

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/950786
推荐阅读
相关标签
  

闽ICP备14008679号