Gift.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="container">
  3. <view id="list-box" class="list-box" :style="{ height: swiperHeight + 'px' }">
  4. <view class="guess-section">
  5. <view v-for="(item, index) in list" :key="index" class="guess-item">
  6. <view class="imagewrapper"><image :src="item.image"></image></view>
  7. <view class="guess-list">
  8. <text class="title clamp margin-c-20">{{ item.store_name }}</text>
  9. <view class="info margin-c-20">{{ item.store_info }}</view>
  10. <view class="tipBox margin-c-20">
  11. <view class="tipsl" v-if="item.keyword != ''">
  12. <text v-for="lss in item.keyword">{{ lss }}</text>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="receive" @click="Getreceive(item)">领取赠品</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import { list,send} from '@/api/user.js';
  24. export default {
  25. data() {
  26. return {
  27. list:'',
  28. swiperHeight: 0,
  29. orderId:''
  30. }
  31. },
  32. onLoad(option) {
  33. this.orderId = option.orderId;
  34. this.loadDate();
  35. },
  36. watch:{
  37. // 初次加载页面高度时修改页面高度
  38. list(newValue, oldValue) {
  39. let obj = this;
  40. let bHeight = Math.ceil(newValue.length / 2);
  41. obj.$nextTick(function() {
  42. uni.createSelectorQuery()
  43. .select('#list-box')
  44. .fields(
  45. {
  46. size: true
  47. },
  48. function(data) {
  49. obj.pageProportion = data.width / 750;
  50. obj.swiperHeight = Math.ceil(obj.pageProportion * 600 * bHeight);
  51. }
  52. )
  53. .exec();
  54. });
  55. }
  56. },
  57. methods: {
  58. loadDate(){
  59. let obj = this;
  60. list({})
  61. .then(function(e) {
  62. obj.list = e.data;
  63. console.log(e)
  64. })
  65. .catch(function(e) {
  66. console.log(e);
  67. });
  68. },
  69. Getreceive(item){
  70. let obj = this;
  71. let id = item.id;
  72. send({
  73. gift_id:id,
  74. order_id:obj.orderId
  75. })
  76. .then(function(e) {
  77. uni.showToast({
  78. title: '领取成功',
  79. type: 'top',
  80. duration: 2000,
  81. icon: 'none'
  82. });
  83. setTimeout(function() {
  84. uni.switchTab({
  85. url: '/pages/user/user'
  86. });
  87. }, 500);
  88. })
  89. .catch(function(e) {
  90. console.log(e);
  91. });
  92. },
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. .container{
  98. padding: 25rpx 0rpx;
  99. background-color: #FFFFFF;
  100. }
  101. /*公用边框样式*/
  102. %icon {
  103. margin-right: 10rpx;
  104. display: inline-block;
  105. padding: 2rpx 10rpx;
  106. border: 1rpx solid $color-yellow;
  107. color: $color-yellow;
  108. line-height: 1;
  109. font-size: $font-base;
  110. border-radius: 10rpx;
  111. }
  112. /* 猜你喜欢 */
  113. .guess-section {
  114. display: flex;
  115. flex-wrap: wrap;
  116. padding: 0 20rpx;
  117. background-color: #FFFFFF;
  118. .guess-item {
  119. // height: 558rpx;
  120. position: relative;
  121. overflow: hidden;
  122. display: flex;
  123. flex-direction: column;
  124. border: 2rpx solid #eeeeee;
  125. width: 343rpx;
  126. margin-bottom: 4%;
  127. border-radius: $border-radius-sm;
  128. background-color: white;
  129. padding-bottom: 30rpx;
  130. &:nth-child(2n + 1) {
  131. margin-right: 24rpx;
  132. }
  133. }
  134. .imagewrapper {
  135. width: 100%;
  136. height: 330rpx;
  137. border-radius: 3px;
  138. margin-bottom: 15rpx;
  139. image {
  140. width: 100%;
  141. height: 100%;
  142. // opacity: 1;
  143. }
  144. }
  145. .guess-list{
  146. height: 190rpx;
  147. .title {
  148. font-size: 28rpx;
  149. color: $font-color-dark;
  150. }
  151. .info {
  152. color: #999999;
  153. font-size: 24rpx;
  154. }
  155. .tipBox{
  156. // padding-bottom: 8rpx;
  157. .tipsl {
  158. text {
  159. border: 2rpx solid #ff1a27;
  160. color: #ff1a27;
  161. border-radius: 5rpx;
  162. font-size: 18rpx;
  163. padding: 2rpx 5rpx;
  164. margin-right: 15rpx;
  165. }
  166. }
  167. }
  168. }
  169. .icon {
  170. @extend %icon;
  171. }
  172. .detail {
  173. line-height: 1;
  174. }
  175. .tip {
  176. color: white;
  177. background-color: $color-yellow;
  178. line-height: 1.5;
  179. font-size: $font-sm;
  180. padding-left: 20rpx;
  181. }
  182. }
  183. .receive{
  184. width: 100%;
  185. background: #2DBD59;
  186. padding: 20rpx 0rpx;
  187. color: #FFFFFF;
  188. text-align: center;
  189. position: absolute;
  190. bottom: 0;
  191. font-size: 28rpx;
  192. }
  193. </style>