joingroup.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view>
  3. <!--components/joingroup/joingroup.wxml-->
  4. <!-- 拼团 -->
  5. <template name="joingroup">
  6. <view class="pdlr20">
  7. <view class="mt20 bgfff r10 " v-if="joingroupList&&joingroupList.products.length > 0">
  8. <navigator hover-class="none" :url="'/activity/group/index/index' + url" class="head">
  9. <view class="titleNav pdlr20 dflex" v-if="joingroupTemplate.titleType==1">
  10. {{joingroupTemplate.titleCon}}
  11. <image src="/static/pages/images/more.png" class="more"></image>
  12. </view>
  13. <image lazy-load="true" v-if="joingroupTemplate.titleType==2" :src="joingroupTemplate.titleCon + '?x-oss-process=style/w750-auto'" mode="widthFix" class="imgtit">
  14. </image>
  15. </navigator>
  16. <goodsList :pageList="joingroupList" :about="about" :merchant="web" :type="'3'" :typeName="'拼团'"></goodsList>
  17. <!-- <view class="pintuan pdlr20">
  18. <view v-for="(item, index) in joingroupList" :key="index" class="li">
  19. <view class="dflex">
  20. <view class="pinimgs" @tap="goUrl" :data-url="'activity/group/detail/detail?acid=' + item.id + '&id=' + item.productId + '' + web">
  21. <image :src="item.pic" mode="aspectFit" class="pinimg"></image>
  22. <view class="tuan">
  23. <image src="/static/pages/images/tagbg.png"></image>
  24. <text>{{item.activityMainEntity.numberPeople}}人团</text>
  25. </view>
  26. </view>
  27. <view class="pininfo flex ">
  28. <view class="proname" @tap="goUrl" :data-url="'activity/group/detail/detail?acid=' + item.id + '&id=' + item.productId + '' + web">
  29. {{item.productName}}</view>
  30. <view :class="'endtime ' + (item.start? '' : 'wei')">{{item.start ? '距结束': '距开始'}} {{item.times}}</view>
  31. <view v-if="item.marketPrice!=0&&item.marketPrice>item.money" class="del" @tap="goUrl" :data-url="'activity/group/detail/detail?acid=' + item.id + '&id=' + item.productId + '' + web">
  32. ¥{{item.marketPrice}}
  33. </view>
  34. <view class="operate dflex">
  35. <view class="price" @tap="goUrl" :data-url="'activity/group/detail/detail?acid=' + item.id + '&id=' + item.productId + '' + web">
  36. 拼团价¥<text>{{item.money}}</text></view>
  37. <view class="add-cart">
  38. <view class="remind mbglinear dflex" v-if="item.start" @tap="goUrl" :data-url="'activity/group/detail/detail?acid=' + item.id + '&id=' + item.productId + '' + web">
  39. 立即开团</view>
  40. <block v-else>
  41. <view class="remind mbggreen dflex" v-if="item.isRemind" @tap="cancelActivityRemind" :data-index="index" data-type="2" :data-id="item.id">取消预约</view>
  42. <view class="remind mbggreen dflex" @tap="addActivityRemind" :data-index="index" data-type="2" :data-id="item.id" v-else>
  43. <icon class="iconfont icon-yugao"></icon>预约提醒
  44. </view>
  45. </block>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view> -->
  52. </view>
  53. </view>
  54. </template>
  55. </view>
  56. </template>
  57. <script>
  58. // components/joingroup/joingroup.js
  59. const route = require("../../utils/route.js");
  60. const utils = require("../../utils/util.js");
  61. const mes = require("../../utils/requestmessage.js");
  62. const req = require("../../utils/request.js");
  63. const app = getApp();
  64. import goodsList from "../../components/goodsList/goodsList";
  65. export default {
  66. data() {
  67. return {
  68. // templateType: {
  69. // module_joingroup: 'joingroup' //拼团
  70. // },
  71. // joingroupList: [] //拼团
  72. // ,
  73. // joingroupTemplate: ""
  74. };
  75. },
  76. components: {goodsList},
  77. props: {
  78. joingroupTemplate:Object, //{backgroundColor:背景颜色,displayStyle: 样式模板,lineNumber:每行几个,products:产品列表}
  79. joingroupList:Object, //拼团后台模板配置
  80. web:String,//跳转地址
  81. url:String,//跳转地址
  82. about:Object //参数配置
  83. },
  84. watch: {
  85. },
  86. mounted() {
  87. // console.log(this.joingroupList)
  88. // this.loadGroup(this.groupTemplate)
  89. },
  90. methods: {
  91. getRqeDatas() {
  92. let that = this; //拼团
  93. let joingroup = that.homeTemplate.filter(it => it.module == that.templateType.module_joingroup);
  94. if (joingroup && joingroup.length > 0 && joingroup[0].state == 0) {
  95. that.setData({
  96. joingroupTemplate: joingroup[0]
  97. });
  98. this.joingroupListFun(joingroup[0]);
  99. }
  100. },
  101. //拼团商品
  102. joingroupListFun(joingroupTemplate) {
  103. let _ts = this;
  104. _ts.clearAllTimer(2);
  105. if (this.merchant && this.merchant.type == 5 || this.shopId && this.merchantId) {
  106. let from = {
  107. page: this.page,
  108. limit: joingroupTemplate.number,
  109. type: 4,
  110. merchantId: this.merchant.merchantDTO.id,
  111. sid: this.merchant.id
  112. };
  113. if (this.shopId && this.merchantId) from.merchantId = this.merchantId, from.sid = this.shopId;
  114. route.getShopeList(from, res => {
  115. res = res.list.map(it => {
  116. it.isRemind = it.remindId;
  117. return it;
  118. });
  119. let arrObjFilter = res.filter(ele => ele.end == false);
  120. this.setData({
  121. joingroupList: arrObjFilter
  122. });
  123. _ts.initGroupTimer(2);
  124. });
  125. }
  126. if (this.merchant && this.merchant.type != 5) {
  127. route.getAcitveNew({
  128. page: 1,
  129. limit: joingroupTemplate.number,
  130. type: 3,
  131. dayType: 1,
  132. tag: 'home'
  133. }, data => {
  134. data = data.list.map(it => {
  135. it.isRemind = it.remindId;
  136. return it;
  137. });
  138. let arrObjFilter = data.filter(ele => ele.end == false);
  139. _ts.setData({
  140. joingroupList: arrObjFilter.slice(0, joingroupTemplate.number)
  141. });
  142. _ts.initGroupTimer(2);
  143. });
  144. }
  145. },
  146. //1为社区团购,2为拼团,3为砍价
  147. initGroupTimer(type) {
  148. //社区拼图定时器
  149. let _ts = this;
  150. let list = [];
  151. if (type == 2) list = this.joingroupList;
  152. if (list && list.length > 0) {
  153. // let activityGroup = this.data.activityGroup;
  154. for (let i = 0, len = list.length; i < len; i++) {
  155. let group = list[i];
  156. let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
  157. let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
  158. let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
  159. if (!group.start) endTime = startTime;
  160. let times = parseInt((endTime - nowTime) / 1000);
  161. let timer = setInterval(() => {
  162. times--;
  163. let data = {};
  164. if (times === 0) {
  165. //重新加载列表
  166. if (type == 2) data['joingroupList[' + i + '].end'] = true;
  167. clearInterval(timer);
  168. } else {
  169. let n = utils.formatDayTimes(times);
  170. if (type == 2) data['joingroupList[' + i + '].times'] = n;
  171. }
  172. _ts.setData(data);
  173. }, 1000);
  174. if (type == 2) this.joingroupList[i]['timer'] = timer; // let fs = [];
  175. // fs['activityGroup[' + i + '].timer'] = timer;
  176. // _ts.setData(fs);
  177. }
  178. }
  179. },
  180. clearAllTimer(type) {
  181. // console.log(this.activityGroup, this.joingroupList, this.bargainList, this.customersList);
  182. if (type == 2) this.joingroupList.forEach(it => clearInterval(it.timer));
  183. },
  184. cancelActivityRemind(event) {
  185. const index = event.currentTarget.dataset.index;
  186. const id = event.currentTarget.dataset.id;
  187. const type = event.currentTarget.dataset.type;
  188. if(req.header.appId=='ZQ1VK5oc17I387E'){
  189. }else{
  190. route.cancelActivityRemind({
  191. id: id
  192. }, res => {
  193. req.msg('取消提醒成功');
  194. let data = {};
  195. if (type == 2) data['joingroupList[' + index + '].isRemind'] = false;
  196. this.setData(data);
  197. });
  198. }
  199. },
  200. addActivityRemind(event) {
  201. const index = event.currentTarget.dataset.index;
  202. const id = event.currentTarget.dataset.id;
  203. const type = event.currentTarget.dataset.type;
  204. route.addActivityRemind({
  205. activityId: id
  206. }, res => {
  207. mes.remind().then(res => res);
  208. // mes.remind().then(res=>res)
  209. // mes.requsetmessage()
  210. req.msg('订阅提醒成功');
  211. let data = {};
  212. if (type == 2) data['joingroupList[' + index + '].isRemind'] = true;
  213. this.setData(data);
  214. });
  215. },
  216. goUrl(event) {
  217. //跳转链接
  218. let url = event.currentTarget.dataset.url;
  219. app.globalData.openPage(url);
  220. }
  221. }
  222. };
  223. </script>
  224. <style>
  225. @import "./joingroup.css";
  226. </style>