huodong.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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.showModal({
  117. title: '提示',
  118. content: res.msg,
  119. success: function (res) {
  120. if (res.confirm) {
  121. } else if (res.cancel) {
  122. }
  123. }
  124. });
  125. }
  126. });
  127. } else {
  128. }
  129. }
  130. })
  131. },
  132. //选择商品
  133. selectShang(activityShopId){
  134. uni.navigateTo({
  135. url:'./select_shang?actShopid='+activityShopId
  136. })
  137. },
  138. //跳转到活动详情
  139. gotoinfo(id){
  140. uni.navigateTo({
  141. url:'./hdInfo?activityId='+id
  142. })
  143. },
  144. // 我参与的活动
  145. getMyHuoDong() {
  146. var shopId=uni.getStorageSync('shopId')
  147. this.$Request.get(`/admin/activity-shop/shop-activity-list/${shopId}`).then(res => {
  148. if (res.code == 0) {
  149. let returnData = res.data
  150. // this.activityId = res.data.activityId
  151. if(res.data.length>0){
  152. this.myhd = res.data[0].activityImage.split(',')
  153. }
  154. //活动列表
  155. this.getHuoDongList(returnData)
  156. }
  157. });
  158. },
  159. getHuoDongList(returnData) {
  160. // this.huodongList = []
  161. let data = {
  162. page: this.page,
  163. limit: this.limit
  164. }
  165. this.$Request.get("/admin/activity/page", data).then(res => {
  166. uni.stopPullDownRefresh()
  167. if (res.code == 0) {
  168. let returnData2 = res.data
  169. const newList =returnData2.list.map(item =>{
  170. return{...item,quantity:0}
  171. return{...item,activityShopId:0}
  172. })
  173. var arr = []
  174. for(var j in returnData){
  175. newList.forEach(item => {
  176. if (item.id === returnData[j].activityId) {
  177. // 'status'为属性名,'非活动'为修改后的内容
  178. item.quantity = 1
  179. item.activityShopId = returnData[j].activityShopId
  180. }
  181. })
  182. }
  183. arr=newList
  184. // this.huodongData = arr
  185. // res.data.list.map(item=>{
  186. // if(item.id==14){
  187. // item.no = '是'
  188. // }
  189. // if(item.id==this.activityId){
  190. // item.se = '是'
  191. // }else{
  192. // item.se = '否'
  193. // }
  194. // })
  195. this.total = res.data.totalCount
  196. if (this.page == 1) {
  197. this.huodongList = arr
  198. } else {
  199. this.huodongList = [...this.huodongList, ...arr]
  200. }
  201. if(this.page == this.total){
  202. this.status = 'nomore'
  203. }else{
  204. this.status = 'loadmore'
  205. }
  206. }
  207. });
  208. },
  209. }
  210. }
  211. </script>
  212. <style lang="scss">
  213. .myswiper {
  214. width: 100%;
  215. height: 340rpx;
  216. z-index: 0;
  217. }
  218. .list {
  219. width: 100%;
  220. height: 160rpx;
  221. .list-box {
  222. width: 686rpx;
  223. height: 100%;
  224. border-radius: 24rpx;
  225. background-color: #ffffff;
  226. margin-bottom: 20rpx;
  227. z-index: 999;
  228. .list-box-c {
  229. width: 646rpx;
  230. height: 100%;
  231. }
  232. .list-box-c-l {
  233. image {
  234. width: 100rpx;
  235. height: 100rpx;
  236. border-radius: 16rpx;
  237. }
  238. .list-box-c-l-txt {
  239. width: 50vw;
  240. height: 100rpx;
  241. margin-left: 20rpx;
  242. font-size: 26rpx;
  243. overflow: hidden;
  244. line-height: 100rpx;
  245. }
  246. }
  247. .list-box-c-r {
  248. // border: 1rpx solid #FCD202;
  249. background: #FCD202;
  250. padding: 10rpx 30rpx 10rpx 30rpx;
  251. // color: #ffffff;
  252. font-size: 26rpx;
  253. border-radius: 24rpx;
  254. }
  255. //退出
  256. .list-box-c-t{
  257. background: rgba(252, 126, 126, 1);
  258. padding: 10rpx 30rpx 10rpx 30rpx;
  259. // color: #ffffff;
  260. font-size: 26rpx;
  261. border-radius: 24rpx;
  262. margin-top: 5px;
  263. text-align: center;
  264. }
  265. }
  266. }
  267. </style>