huodong.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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.id != 14" v-for="(item,index) in huodongList" :key="index" @click="item.quantity==0 &&item.id != 14?gotoinfo(item.id):''">
  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.image.split(',')[0]" style="width: 100rpx;height: 100rpx;" mode="aspectFill"></image>
  19. <view class="list-box-c-l-txt">
  20. {{item.title}}
  21. </view>
  22. </view>
  23. <view class="list-box-c-r" v-if="item.quantity==0" @click.stop="joinHd(item.id,index)">
  24. 加入
  25. </view>
  26. <view v-else>
  27. <!-- <view class="list-box-c-r">
  28. 已加入
  29. </view> -->
  30. <view class="list-box-c-t" @click="selectShang(item.activityShopId )" v-if="item.type=='3'">
  31. 选择商品
  32. </view>
  33. <view class="list-box-c-t" @click.stop="quitHuo(item.id)">
  34. 退出
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <u-loadmore :status="status" v-if="huodongList.length>0" :icon-type="iconType" :load-text="loadText" />
  40. </view>
  41. <view class="flex justify-center flex-wrap" v-if="huodongList.length==0">
  42. <image src="../../static/images/img/empty.png" style="width: 387rpx;height: 341rpx;margin-top: 100rpx;" mode=""></image>
  43. <view class="" style="width: 100%;text-align: center;margin-top: 20rpx;">
  44. 暂无数据
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. myhd:[],
  54. page: 1,
  55. limit: 10,
  56. huodongList: [],
  57. total: 1,
  58. status: 'loadmore',
  59. iconType: 'flower',
  60. activityId:'',
  61. loadText: {
  62. loadmore: '上拉加载更多',
  63. loading: '努力加载中',
  64. nomore: '实在没有了'
  65. },
  66. };
  67. },
  68. onLoad() {
  69. //我参与的活动
  70. this.getMyHuoDong()
  71. },
  72. onShow() {
  73. //我参与的活动
  74. this.getMyHuoDong()
  75. },
  76. //加载更多
  77. onReachBottom() {
  78. if(this.page < this.total){
  79. this.page += 1
  80. this.status = 'loading'
  81. //我参与的活动
  82. this.getMyHuoDong()
  83. }
  84. },
  85. //下拉刷新
  86. onPullDownRefresh() {
  87. this.page = 1
  88. this.getMyHuoDong()
  89. },
  90. methods: {
  91. //加入活动
  92. joinHd(id,index) {
  93. uni.navigateTo({
  94. url:'./join_huodong?activityId='+id+'&shunxu='+index
  95. })
  96. },
  97. //退出活动
  98. quitHuo(row){
  99. uni.showModal({
  100. title: '提示',
  101. content: '确定退出该活动?',
  102. success: (res) => {
  103. if(res.confirm) {
  104. let data = {
  105. "shopId":uni.getStorageSync('shopId'),
  106. "activityId": row
  107. }
  108. this.$Request.put("/admin/activity-shop/quit", data).then(res => {
  109. if(res.code==0){
  110. uni.showToast({
  111. title: '操作成功',
  112. icon: 'success'
  113. })
  114. this.getMyHuoDong()
  115. }else{
  116. uni.showToast({
  117. title: res.msg,
  118. icon: 'none'
  119. })
  120. }
  121. });
  122. } else {
  123. }
  124. }
  125. })
  126. },
  127. //选择商品
  128. selectShang(activityShopId){
  129. uni.navigateTo({
  130. url:'./select_shang?actShopid='+activityShopId
  131. })
  132. },
  133. //跳转到活动详情
  134. gotoinfo(id){
  135. uni.navigateTo({
  136. url:'./hdInfo?activityId='+id
  137. })
  138. },
  139. // 我参与的活动
  140. getMyHuoDong() {
  141. var shopId=uni.getStorageSync('shopId')
  142. this.$Request.get(`/admin/activity-shop/shop-activity-list/${shopId}`).then(res => {
  143. if (res.code == 0) {
  144. let returnData = res.data
  145. // this.activityId = res.data.activityId
  146. this.myhd = res.data[0].activityImage.split(',')
  147. //活动列表
  148. this.getHuoDongList(returnData)
  149. }
  150. });
  151. },
  152. getHuoDongList(returnData) {
  153. // this.huodongList = []
  154. let data = {
  155. page: this.page,
  156. limit: this.limit
  157. }
  158. this.$Request.get("/admin/activity/page", data).then(res => {
  159. uni.stopPullDownRefresh()
  160. if (res.code == 0) {
  161. let returnData2 = res.data
  162. const newList =returnData2.list.map(item =>{
  163. return{...item,quantity:0}
  164. return{...item,activityShopId:0}
  165. })
  166. var arr = []
  167. for(var j in returnData){
  168. newList.forEach(item => {
  169. if (item.id === returnData[j].activityId) {
  170. // 'status'为属性名,'非活动'为修改后的内容
  171. item.quantity = 1
  172. item.activityShopId = returnData[j].activityShopId
  173. }
  174. })
  175. }
  176. arr=newList
  177. // this.huodongData = arr
  178. // res.data.list.map(item=>{
  179. // if(item.id==14){
  180. // item.no = '是'
  181. // }
  182. // if(item.id==this.activityId){
  183. // item.se = '是'
  184. // }else{
  185. // item.se = '否'
  186. // }
  187. // })
  188. this.total = res.data.totalCount
  189. if (this.page == 1) {
  190. this.huodongList = arr
  191. } else {
  192. this.huodongList = [...this.huodongList, ...arr]
  193. }
  194. if(this.page == this.total){
  195. this.status = 'nomore'
  196. }else{
  197. this.status = 'loadmore'
  198. }
  199. }
  200. });
  201. },
  202. }
  203. }
  204. </script>
  205. <style lang="scss">
  206. .myswiper {
  207. width: 100%;
  208. height: 340rpx;
  209. z-index: 0;
  210. }
  211. .list {
  212. width: 100%;
  213. height: 160rpx;
  214. .list-box {
  215. width: 686rpx;
  216. height: 100%;
  217. border-radius: 24rpx;
  218. background-color: #ffffff;
  219. margin-bottom: 20rpx;
  220. z-index: 999;
  221. .list-box-c {
  222. width: 646rpx;
  223. height: 100%;
  224. }
  225. .list-box-c-l {
  226. image {
  227. width: 100rpx;
  228. height: 100rpx;
  229. border-radius: 16rpx;
  230. }
  231. .list-box-c-l-txt {
  232. width: 50vw;
  233. height: 100rpx;
  234. margin-left: 20rpx;
  235. font-size: 26rpx;
  236. overflow: hidden;
  237. line-height: 100rpx;
  238. }
  239. }
  240. .list-box-c-r {
  241. // border: 1rpx solid #FCD202;
  242. background: #FCD202;
  243. padding: 10rpx 30rpx 10rpx 30rpx;
  244. // color: #ffffff;
  245. font-size: 26rpx;
  246. border-radius: 24rpx;
  247. }
  248. //退出
  249. .list-box-c-t{
  250. background: rgba(252, 126, 126, 1);
  251. padding: 10rpx 30rpx 10rpx 30rpx;
  252. // color: #ffffff;
  253. font-size: 26rpx;
  254. border-radius: 24rpx;
  255. margin-top: 5px;
  256. text-align: center;
  257. }
  258. }
  259. }
  260. </style>