huodong.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view>
  3. <!-- swiper -->
  4. <view class="myswiper flex justify-center align-center" v-if="myhd.length!=0">
  5. <swiper :indicator-dots="false" style="width: 100%;height: 100%;" :autoplay="true" :interval="3000" :duration="300">
  6. <swiper-item v-for="(item,index) in myhd" :key="index">
  7. <view class="swiper-item">
  8. <image :src="item" style="width: 100%;height: 340rpx;" mode="aspectFill"></image>
  9. </view>
  10. </swiper-item>
  11. </swiper>
  12. </view>
  13. <!-- 活动列表 -->
  14. <view :style="myhd.length==0?'margin-top: 20rpx;':'margin-top: -40rpx;'" class="list flex justify-center flex-wrap">
  15. <view class="list-box flex justify-center" v-if="item.no != '是'" v-for="(item,index) in huodongList" :key="index" @click="item.se!='是'?gotoinfo(item.activityId):''">
  16. <view class="list-box-c flex justify-between align-center">
  17. <view class="list-box-c-l flex align-center">
  18. <image :src="item.activityImage.split(',')[0]" style="width: 100rpx;height: 100rpx;" mode="aspectFill"></image>
  19. <view class="list-box-c-l-txt">
  20. {{item.activityTitle}}
  21. </view>
  22. </view>
  23. <view class="list-box-c-r" v-if="item.se!='是'" @click.stop="joinHd(item.activityId)">
  24. 加入
  25. </view>
  26. <view class="list-box-c-r" v-else>
  27. 已加入
  28. </view>
  29. </view>
  30. </view>
  31. <u-loadmore :status="status" v-if="huodongList.length>0" :icon-type="iconType" :load-text="loadText" />
  32. </view>
  33. <view class="flex justify-center flex-wrap" v-if="huodongList.length==0">
  34. <image src="../../static/images/img/empty.png" style="width: 387rpx;height: 341rpx;margin-top: 100rpx;" mode=""></image>
  35. <view class="" style="width: 100%;text-align: center;margin-top: 20rpx;">
  36. 暂无数据
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. myhd:[],
  46. page: 1,
  47. limit: 10,
  48. huodongList: [],
  49. total: 1,
  50. status: 'loadmore',
  51. iconType: 'flower',
  52. activityId:'',
  53. loadText: {
  54. loadmore: '上拉加载更多',
  55. loading: '努力加载中',
  56. nomore: '实在没有了'
  57. }
  58. };
  59. },
  60. onLoad() {
  61. //我参与的活动
  62. this.getMyHuoDong()
  63. //活动列表
  64. this.getHuoDongList();
  65. },
  66. onShow() {
  67. //我参与的活动
  68. this.getMyHuoDong()
  69. //活动列表
  70. this.getHuoDongList();
  71. },
  72. //加载更多
  73. onReachBottom() {
  74. if(this.page < this.total){
  75. this.page += 1
  76. this.status = 'loading'
  77. this.getHuoDongList()
  78. }
  79. },
  80. //下拉刷新
  81. onPullDownRefresh() {
  82. this.page = 1
  83. this.getHuoDongList()
  84. this.getMyHuoDong()
  85. },
  86. methods: {
  87. //加入活动
  88. joinHd(activityId) {
  89. let that = this
  90. let data = {
  91. activityId: activityId,
  92. shopId: uni.getStorageSync('shopId')
  93. }
  94. this.$Request.get("/app/activityManage/shopJoinActivity", data).then(res => {
  95. if (res.code == 0) {
  96. uni.showModal({
  97. title: '提示',
  98. content: '加入该活动将自动退出当前活动,确定加入该活动?',
  99. complete(ret) {
  100. if (ret.confirm) {
  101. uni.showToast({
  102. title: '加入成功'
  103. })
  104. //我参与的活动
  105. that.getMyHuoDong()
  106. //活动列表
  107. that.getHuoDongList();
  108. }
  109. }
  110. })
  111. } else {
  112. uni.showToast({
  113. title: res.msg,
  114. icon: 'none'
  115. })
  116. }
  117. });
  118. },
  119. gotoinfo(activityId){
  120. uni.navigateTo({
  121. url:'./hdInfo?activityId='+activityId
  122. })
  123. },
  124. // 我参与的活动
  125. getMyHuoDong() {
  126. let data = {
  127. shopId:uni.getStorageSync('shopId')
  128. }
  129. this.$Request.get("/app/goods/getShopActivity", data).then(res => {
  130. if (res.code == 0) {
  131. this.activityId = res.data.activityId
  132. this.myhd = res.data.activityImage.split(',')
  133. }
  134. });
  135. },
  136. getHuoDongList() {
  137. let data = {
  138. page: this.page,
  139. limit: this.limit
  140. }
  141. this.$Request.getT("/app/activityManage/getActivityList", data).then(res => {
  142. uni.stopPullDownRefresh()
  143. if (res.code == 0) {
  144. res.data.records.map(item=>{
  145. if(item.activityId==14){
  146. item.no = '是'
  147. }
  148. if(item.activityId==this.activityId){
  149. item.se = '是'
  150. }else{
  151. item.se = '否'
  152. }
  153. })
  154. this.total = res.data.pages
  155. if (this.page == 1) {
  156. this.huodongList = res.data.records
  157. } else {
  158. this.huodongList = [...this.huodongList, ...res.data.records]
  159. }
  160. if(this.page == this.total){
  161. this.status = 'nomore'
  162. }else{
  163. this.status = 'loadmore'
  164. }
  165. }
  166. });
  167. },
  168. }
  169. }
  170. </script>
  171. <style lang="scss">
  172. .myswiper {
  173. width: 100%;
  174. height: 340rpx;
  175. z-index: 0;
  176. }
  177. .list {
  178. width: 100%;
  179. height: 160rpx;
  180. .list-box {
  181. width: 686rpx;
  182. height: 100%;
  183. border-radius: 24rpx;
  184. background-color: #ffffff;
  185. margin-bottom: 20rpx;
  186. z-index: 999;
  187. .list-box-c {
  188. width: 646rpx;
  189. height: 100%;
  190. }
  191. .list-box-c-l {
  192. image {
  193. width: 100rpx;
  194. height: 100rpx;
  195. border-radius: 16rpx;
  196. }
  197. .list-box-c-l-txt {
  198. width: 50vw;
  199. height: 100rpx;
  200. margin-left: 20rpx;
  201. font-size: 26rpx;
  202. overflow: hidden;
  203. line-height: 100rpx;
  204. }
  205. }
  206. .list-box-c-r {
  207. // border: 1rpx solid #FCD202;
  208. background: #FCD202;
  209. padding: 10rpx 30rpx 10rpx 30rpx;
  210. // color: #ffffff;
  211. font-size: 26rpx;
  212. border-radius: 24rpx;
  213. }
  214. }
  215. }
  216. </style>