activity.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="box">
  3. <view class="itemHistory" v-for="(item,index) in itemData" :key="index" @click="goDetail(item.id)">
  4. <image :src="item.img" mode="" class="itemImg"></image>
  5. <view class="timeBox">
  6. <image v-if="item.state==2" src="../../static/img/bg_huangse.png" mode="" class="state"></image>
  7. <image v-if="item.state==1" src="../../static/img/bg_hongse.png" mode="" class="state"></image>
  8. <view class="time" v-if="item.startTime">{{item.startTime.slice(0,10)}}-{{item.endTime.slice(0,10)}}</view>
  9. </view>
  10. <view class="name">{{item.activityName}}</view>
  11. </view>
  12. <!-- 上拉 加载更多 -->
  13. <view class="noMore" v-if="noMoreShow && (itemData.length!=0)">没有更多数据</view>
  14. <!-- 无数据空白页 -->
  15. <nodata v-if="itemData.length==0"></nodata>
  16. <!-- 手机号授权 -->
  17. <view class="authorizBox" v-if="authorizShow" @click="authorizShow=false">
  18. <view class="authorizCont" @click.stop="">
  19. <view class="authorizName">{{wxOpenData.miniAppName}}</view>
  20. <view class="authorizMs">您好,欢迎访问本店,授权手机号登录能获取我们最新的促销活动哦~</view>
  21. <button class="authorizContbutton" type="default" open-type="getPhoneNumber"
  22. @getphonenumber="decryptPhoneNumber">授权</button>
  23. </view>
  24. <view style="text-align: center;padding-top: 56rpx;">
  25. <image src="../../static/timg/icon_guanbi@2x.png" mode="" class="authorizCloseImg"></image>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script scoped>
  31. import nodata from '../../components/nodata/nodata.vue'
  32. export default {
  33. components: {
  34. nodata,
  35. },
  36. data() {
  37. return {
  38. userInfo: '',
  39. authorizShow: false,
  40. code: '',
  41. wxOpenData: '',
  42. page: 1,
  43. itemData: [],
  44. noMoreShow: false,
  45. ext:'',
  46. themeColor:'',
  47. }
  48. },
  49. onLoad() {
  50. this.userInfo = this.$store.state.userInfo;
  51. this.wxOpenData = this.$store.state.wxOpenData
  52. this.ext=this.$common.getExtStoreId();
  53. this.page = 1
  54. this.myOrderCoupon();
  55. this.themeColor = uni.getStorageSync("themeColor");
  56. if(this.themeColor){
  57. if(this.themeColor=='6F2BE8'){
  58. var backgroundImage='/static/tabimg/activty6F2BE8.png'
  59. }
  60. if(this.themeColor=='1677FF'){
  61. var backgroundImage='/static/tabimg/activty1677FF.png'
  62. }
  63. if(this.themeColor=='FF4F00'){
  64. var backgroundImage='/static/tabimg/activtyFF4F00.png'
  65. }
  66. if(this.themeColor=='D53533'){
  67. var backgroundImage='/static/tabimg/activity1.png'
  68. }
  69. uni.setTabBarStyle({
  70. // color: '#FF0000',
  71. selectedColor: '#'+this.themeColor,
  72. })
  73. uni.setTabBarItem({
  74. index: 2,
  75. text: '活动',
  76. selectedIconPath: backgroundImage
  77. })
  78. }
  79. },
  80. methods: {
  81. goDetail(id) {
  82. uni.navigateTo({
  83. url: 'jkDetail?id=' + id
  84. })
  85. },
  86. myOrderCoupon() {
  87. uni.showLoading({
  88. title: '加载中'
  89. })
  90. this.$http('openHome/queryActivityList', {
  91. // page: this.page,
  92. // limit: 10,
  93. unionId:this.ext.unionId
  94. }, 'GET').then(res => {
  95. uni.hideLoading();
  96. // var list = res.data.Items
  97. var list = res.data
  98. // 处理 undefined和null转为空白字符串
  99. // list.forEach((item, index) => {
  100. // for (const key in item) {
  101. // item[key] = this.$praseStrEmpty(item[key])
  102. // }
  103. // })
  104. if (this.page == 1) {
  105. this.itemData = list
  106. } else {
  107. this.itemData = this.itemData.concat(list)
  108. }
  109. if (list.length < 10) {
  110. this.noMoreShow = true
  111. } else {
  112. this.noMoreShow = false
  113. }
  114. })
  115. },
  116. },
  117. // 下拉刷新 上拉加载更多
  118. onPullDownRefresh() {
  119. this.page = 1
  120. this.myOrderCoupon()
  121. setTimeout(function() {
  122. uni.stopPullDownRefresh();
  123. }, 1000);
  124. },
  125. onReachBottom() {
  126. // this.page++;
  127. this.myOrderCoupon()
  128. },
  129. }
  130. </script>
  131. <style scoped lang="less">
  132. .box {
  133. background: #F4F5F7;
  134. min-height: 100vh;
  135. padding-top: 20rpx;
  136. }
  137. .authorizBox {
  138. width: 100vw;
  139. height: 100vh;
  140. background: rgba(0, 0, 0, 0.5);
  141. position: fixed;
  142. top: 0;
  143. left: 0;
  144. }
  145. .authorizCont {
  146. margin-top: 30vh;
  147. width: 564rpx;
  148. height: 408rpx;
  149. background: #FFFFFF;
  150. border-radius: 24rpx;
  151. margin-left: 93rpx;
  152. position: relative;
  153. }
  154. .authorizCloseImg {
  155. width: 62rpx;
  156. height: 62rpx;
  157. }
  158. .sqLogoBox {
  159. width: 180rpx;
  160. height: 180rpx;
  161. background: #FFFFFF;
  162. border-radius: 90rpx;
  163. text-align: center;
  164. position: absolute;
  165. top: -50rpx;
  166. left: 192rpx;
  167. }
  168. .authorizName {
  169. color: #333333;
  170. line-height: 42rpx;
  171. font-size: 30rpx;
  172. text-align: center;
  173. padding-top: 58rpx;
  174. }
  175. .authorizMs {
  176. color: #999999;
  177. line-height: 36rpx;
  178. font-size: 26rpx;
  179. width: 452rpx;
  180. padding-top: 24rpx;
  181. text-align: center;
  182. margin-left: 56rpx;
  183. }
  184. .authorizContbutton {
  185. width: 422rpx;
  186. height: 88rpx;
  187. background: #D53533;
  188. border-radius: 44rpx;
  189. line-height: 88rpx;
  190. text-align: center;
  191. font-size: 30rpx;
  192. color: #FFFFFF;
  193. margin-top: 62rpx;
  194. margin-left: 71rpx;
  195. }
  196. .itemHistory {
  197. margin: 0rpx 24rpx 20rpx;
  198. background-color: #FFFFFF;
  199. border-radius: 10rpx;
  200. }
  201. .itemImg {
  202. height: 280rpx;
  203. width: 702rpx;
  204. border-radius: 10rpx 10rpx 0px 0px;
  205. display: block;
  206. }
  207. .timeBox {
  208. display: flex;
  209. margin-top: -61rpx;
  210. align-items: flex-end;
  211. }
  212. .state{
  213. width: 102rpx;
  214. height: 53rpx;
  215. position: relative;
  216. }
  217. .time {
  218. padding: 5rpx 10rpx;
  219. color: #FFFFFF;
  220. font-size: 24rpx;
  221. background: rgba(0, 0, 0, 0.5);
  222. margin-left: -8rpx;
  223. border-radius: 0 10rpx 0 0;
  224. }
  225. .name {
  226. padding: 24rpx 20rpx;
  227. color: #333333;
  228. font-size: 28rpx;
  229. background: #FFFFFF;
  230. border-radius: 0 0 10rpx 10rpx;
  231. }
  232. .noMore {
  233. text-align: center;
  234. line-height: 50rpx;
  235. color: #999999;
  236. font-size: 28rpx;
  237. }
  238. </style>