activityDetail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <view :style="[mainStyle]" v-if="isShow">
  3. <view class="top">
  4. <view class="banner">
  5. <swiper class="swiper" @change="swiperChange" autoplay="true" interval="5000" duration="300">
  6. <block v-for="(item, index) in detail.imageList" :key="index">
  7. <swiper-item @click="clickBanner(item)"><image lazy-load="true" :src="item.url" mode="aspectFill"></image></swiper-item>
  8. </block>
  9. </swiper>
  10. <view class="dots dflex" v-if="detail.imageList.length > 1">
  11. <block v-for="(item, index) in detail.imageList" :key="index"><view :class="['dot', index == swiperCurrent ? 'active' : '']"></view></block>
  12. </view>
  13. </view>
  14. <!-- <image :src="detail.imageList[0]" mode="aspectFill" class="act-img"></image> -->
  15. <view class="title">{{detail.title}}</view>
  16. <view class="xq-datas ddflex">
  17. <view class="xq-data fflex ddflex">
  18. <view class="datas ddflex"><image src="../static/images/xq_llico.png" style="width: 32rpx;height: 24rpx;"></image>{{detail.popularity}}</view>
  19. <view class="datas ddflex"><image src="../static/images/xq_fxico.png" style="width: 26rpx;height: 26rpx;"></image>{{detail.share}}</view>
  20. <view class="datas ddflex"><image src="../static/images/xq_scico.png" style="width: 29rpx;height: 28rpx;"></image>{{detail.collect}}</view>
  21. </view>
  22. <view class="tuibao ddflex">
  23. <view class="ddflex"><image src="../static/images/xq_bao.png"></image>交易保障</view>
  24. <view class="ddflex"><image src="../static/images/xq_tui.png"></image>支持退款</view>
  25. </view>
  26. </view>
  27. <!-- <view class="money free" v-if="userinfovip.levelGrade>0&& !userinfovip.end"><text>¥</text>{{detail.vipMoney}}</view> -->
  28. <view class="money free"><text v-if="detail.money > 0">¥</text>{{detail.money > 0 ? detail.money : '免费'}}</view>
  29. </view>
  30. <view class="date">
  31. <view class="datass ddflex">
  32. <image src="../static/images/xq_sjico.png" class="dimg"></image>
  33. <view>{{ getTimeText(detail.startTime,detail.endTime,true) }}</view>
  34. </view>
  35. <view class="datass ddflex" style="align-items: flex-start;" v-if="detail.address" @click="openMap()">
  36. <image src="../static/images/xq_dzico.png" class="dimg" style="margin-top: 5rpx;"></image>
  37. <view class="fflex">{{detail.address}}</view>
  38. <image src="../../static/pages/images/crico1.png" class="rico" style="margin-top: 10rpx;"></image>
  39. </view>
  40. <view class="datass ddflex">
  41. <image src="../static/images/xq_rsico.png" class="dimg"></image>
  42. <view class="fflex">已报名{{detail.person}}人</view>
  43. </view>
  44. <view class="act-sta" v-if="detail.state == 1">活动报名尚未开始</view>
  45. <view class="sign-user ddflex" v-else>
  46. <swiper class="sign-user-swiper" :autoplay="true" :disable-touch="true" :vertical="true" v-if="enlistUserList.length >0">
  47. <swiper-item class="ddflex" v-for="(it,idx) in enlistUserList" :key="index">
  48. <image :src="item.avatar ? item.avatar : '../../static/pages/images/userimg.png'" mode="aspectFill" v-for="item,index in it" :key="index"></image>
  49. </swiper-item>
  50. </swiper>
  51. <!-- <image :src="item.avatar ? item.avatar : '../../static/pages/images/userimg.png'" mode="aspectFill" v-for="item,index in enlistUserList" :key="index"></image> -->
  52. </view>
  53. <image src="../static/images/sta_not.png" class="sta-img" v-if="detail.state == 1"></image>
  54. <image src="../static/images/sta_ing.png" class="sta-img" v-if="detail.state == 2"></image>
  55. <image src="../static/images/sta_end.png" class="sta-img" v-if="detail.state == 3"></image>
  56. <image src="../static/images/sta_ing_hd.png" class="sta-img" v-if="detail.state == 4"></image>
  57. <image src="../static/images/sta_end_hd.png" class="sta-img" v-if="detail.state == 5"></image>
  58. </view>
  59. <view class="zhubanf dflex">
  60. <view class="fflex">
  61. <view class="zbf-name ddflex">{{detail.partyName}}</view>
  62. <view class="zbf-bri"><rich-text :nodes="detail.partyBrief"></rich-text></view>
  63. </view>
  64. <!-- <image src="../static/images/vip_bg.png" mode="aspectFill" class="zbf-logo"></image>
  65. <view class="fflex">
  66. <view class="zbf-name ddflex">黄飞鸿热炙理疗馆<text class="zbf-tag">优选</text></view>
  67. <view class="zbf-bri">养生理疗 中电软件园</view>
  68. </view>
  69. <image src="../../static/pages/images/crico1.png" class="rico"></image> -->
  70. </view>
  71. <view class="det">
  72. <view class="tit ddflex">活动介绍<!-- <image src="../../static/pages/images/crico1.png" class="rico"></image> --></view>
  73. <view class="content">
  74. <mp-html :content="detail.text" :lazy-load="true" @imgtap="choose"></mp-html>
  75. </view>
  76. </view>
  77. <view style="height: 120rpx;"></view>
  78. <view class="bot fixed bgfff ddflex">
  79. <view class="btnfot ddflex">
  80. <!-- #ifdef H5 -->
  81. <navigator class="botbtn" url="/match/activity/activity" hover-class="none">
  82. <image src="../static/images/sy.png"></image>主页
  83. </navigator>
  84. <!-- #endif -->
  85. <!-- #ifndef H5 -->
  86. <navigator class="botbtn" url="/pages/index/index" hover-class="none">
  87. <image src="../static/images/sy.png"></image>主页
  88. </navigator>
  89. <!-- #endif -->
  90. <view class="botbtn" @tap="clickCollect">
  91. <image src="../static/images/sc_h.png" v-if="detail.isCollect"></image>
  92. <image src="../static/images/sc.png" v-else></image>收藏
  93. </view>
  94. <view class="botbtn" @click="showShare"><image src="../static/images/fx.png"></image>分享</view>
  95. <!-- <button open-type="share" class="botbtn">
  96. <image src="../../static/pages/images/fxico1_1.png"></image>分享
  97. </button> -->
  98. </view>
  99. <view class="btns" v-if="!isIos">
  100. <view class="btn" @click="jumpUrl('/match/activitys/activity')" v-if="detail.isEnlist">我已报名</view>
  101. <block v-else>
  102. <view class="btn end" v-if="detail.state == 1">报名未开始</view>
  103. <view class="btn" @click="showPop()" v-if="detail.state == 2">立即报名</view>
  104. <view class="btn end" v-if="detail.state == 3">报名结束</view>
  105. <view class="btn" v-if="detail.state == 4">活动中</view>
  106. <view class="btn end" v-if="detail.state == 5">活动结束</view>
  107. </block>
  108. </view>
  109. <view class="btns" v-else>
  110. <view class="btn">立即报名</view>
  111. </view>
  112. </view>
  113. <view class="ceng" v-if="popShow" @click="hidePop()"></view>
  114. <view class="popup" v-if="popShow">
  115. <image src="../../static/pages/images/clear.png" class="close" @click="hidePop()"></image>
  116. <view class="p-title">{{detail.title}}</view>
  117. <view class="p-bri tovers">{{detail.brief}}</view>
  118. <view class="money p-money free"><text v-if="price > 0">¥</text>{{price > 0?price:'免费'}}</view>
  119. <view class="pop-tit">报名项目</view>
  120. <view class="pop-con">
  121. <view class="p-list ddflex">
  122. <view :class="'li' + (priceIndex == index ? ' active' : '')" v-for="(item,index) in priceList" :key="index" @click="selProject(item,index)">{{item.title}}</view>
  123. </view>
  124. </view>
  125. <view class="pop-btn" @click="jumpUrl('/match/sign/sign?id=' + detail.id + '&priceId=' + priceId + '&personCount=' + personCount)">马上报名</view>
  126. </view>
  127. <!-- #ifndef H5 -->
  128. <v-share :hide-toast="hideShare" :product="detail" :code-url="codeUrl" @onFather="click"></v-share>
  129. <!-- #endif -->
  130. <!-- #ifdef H5 -->
  131. <view class="share-pop" @click="hideSharePop" v-if="isShowSharePop">
  132. <image src="../static/fx-tip1.png"></image>
  133. </view>
  134. <wx-share :title="detail.title" :image="detail.pic" :desc="detail.brief" :type="2" :id="options.id" />
  135. <!-- #endif -->
  136. </view>
  137. </template>
  138. <script>
  139. const req = require('../../utils/request.js');
  140. const api = require('../../utils/api.js');
  141. const util = require('../../utils/util.js');
  142. const app = getApp();
  143. import mpHtml from "../../components/mp-html/components/mp-html/mp-html";
  144. import vShare from "../components/share-activity/share";
  145. export default {
  146. components: {
  147. mpHtml,
  148. vShare
  149. },
  150. data() {
  151. return {
  152. appId: '',
  153. mainStyle: app.globalData.mainStyle,
  154. isShow: false,
  155. options: {},
  156. detail: {},
  157. swiperCurrent: 0,
  158. isLogin: false,
  159. userinfovip: {},
  160. isIos: false,
  161. priceIndex: 0,
  162. priceList: [],
  163. popShow: false,
  164. priceId: '',
  165. personCount: 1,//价格档位对应的人数
  166. price: 0,
  167. hideShare: true,
  168. codeUrl: '',
  169. about: '',
  170. enlistUserList: [],//报名人员
  171. initEnlistUserList: [],//真实报名人员
  172. isShowSharePop: false,
  173. isFirst: true
  174. };
  175. },
  176. async onLoad(options) {
  177. // #ifdef H5
  178. if(options.appId) req.setStorage('appId',options.appId);
  179. if(options['amp;appId']) req.setStorage('appId',options['amp;appId']);
  180. // #endif
  181. // #ifdef MP-WEIXIN
  182. uni.showShareMenu({
  183. withShareTicket: true,
  184. menus: ['shareAppMessage', 'shareTimeline']
  185. });
  186. // #endif
  187. this.options = options;
  188. // req.silenceLogin(options.userId, '');
  189. await this.loadCodeParams();
  190. await this.getConfig();
  191. await this.getData(true);
  192. if(this.isLogin){
  193. await this.getuserVip();
  194. this.getEnlistUser();
  195. }
  196. this.getBrowse();
  197. await this.getPrice();
  198. },
  199. async onShow() {
  200. this.appId = req.getStorage('appId')
  201. this.isLogin = req.isAuth();
  202. if(!this.isFirst) {
  203. await this.getData(true);
  204. if(this.isLogin){
  205. await this.getuserVip();
  206. this.getEnlistUser();
  207. }
  208. this.getBrowse();
  209. await this.getPrice();
  210. }
  211. },
  212. onReachBottom: function() {
  213. },
  214. onShareAppMessage: function() {
  215. let url = '/match/activityDetail/activityDetail?id=' + this.detail.id
  216. if(req.getStorage('userInfo')){
  217. url += '&userId=' + req.getStorage('userInfo').id
  218. }
  219. this.saveShareBehavior();
  220. return {
  221. title: this.detail.title,
  222. imageUrl: this.detail.pic,
  223. path: url
  224. };
  225. },
  226. onShareTimeline() {
  227. let query = {
  228. id: this.detail.id
  229. }
  230. if(req.getStorage('userInfo')){
  231. query.userId = req.getStorage('userInfo').id
  232. }
  233. this.saveShareBehavior();
  234. return {
  235. title: this.detail.title,
  236. imageUrl: this.detail.pic,
  237. query: query
  238. };
  239. },
  240. methods: {
  241. showSharePop() {
  242. this.isShowSharePop = true;
  243. },
  244. hideSharePop() {
  245. this.isShowSharePop = false;
  246. },
  247. swiperChange(e) {
  248. if(e.detail.source == 'autoplay' || e.detail.source == 'touch') this.swiperCurrent = e.detail.current;
  249. },
  250. getTimeText(startTime,endTime,isText){
  251. return util.getTimeText(startTime,endTime,isText);
  252. },
  253. group(array, subGroupLength) {
  254. let index = 0;
  255. let newArray = [];
  256. while (index < array.length) {
  257. newArray.push(array.slice(index, index += subGroupLength));
  258. }
  259. return newArray;
  260. },
  261. getMachAvatarList(num){
  262. req.getRequest(api.match_avatar_list,{random: num},data=>{
  263. let arr = this.initEnlistUserList;
  264. arr = arr.concat(data);
  265. console.log('arr==',arr)
  266. let newArr = this.group(arr,5);
  267. this.enlistUserList = newArr;
  268. console.log('newArr==',newArr)
  269. })
  270. },
  271. getEnlistUser(){
  272. let form = {
  273. page: 1,
  274. limit: 10,
  275. matchId: this.options.id
  276. }
  277. req.getRequest('/api/match/enlist/user',form,data=>{
  278. if(this.detail.person > data.length){
  279. let num = this.detail.person - data.length;
  280. this.initEnlistUserList = data;
  281. this.getMachAvatarList(num);
  282. }else{
  283. let newArr = this.group(data,5);
  284. this.enlistUserList = newArr;
  285. }
  286. })
  287. },
  288. getConfig() {
  289. var _this = this;
  290. return new Promise((resolve, reject) => {
  291. req.getRequest('/api/config', {}, function(res) {
  292. _this.about = res;
  293. _this.getSystem();
  294. resolve();
  295. });
  296. });
  297. },
  298. getSystem(){
  299. if(uni.getSystemInfoSync().platform == 'ios'){
  300. if(this.about.is_open_iosPay == 1){
  301. this.isIos = false;
  302. }else{
  303. this.isIos = true;
  304. }
  305. }else{
  306. this.isIos = false;
  307. }
  308. },
  309. openMap(){
  310. let that = this;
  311. console.log('打开地图')
  312. uni.openLocation({
  313. latitude: Number(that.detail.lat),
  314. longitude: Number(that.detail.lng),
  315. address: that.detail.address,
  316. success: function () {
  317. console.log('success');
  318. },
  319. fail(res){
  320. console.log('fail=='+JSON.stringify(res))
  321. }
  322. })
  323. },
  324. getData(isShow){
  325. return new Promise((resolve, reject) => {
  326. req.getRequest('/api/match/detail',{id: this.options.id},res => {
  327. this.detail = res;
  328. this.isShow = true;
  329. this.isFirst = false;
  330. resolve();
  331. },isShow);
  332. })
  333. },
  334. getPrice(){
  335. return new Promise((resolve, reject) => {
  336. req.getRequest('/api/match/price',{id: this.options.id},res=>{
  337. this.priceList = res;
  338. this.priceId = res[0].id;
  339. this.personCount = res[0].personCount;
  340. let price = 0;
  341. if(this.userinfovip.levelGrade>0&& !this.userinfovip.end){
  342. price = res[0].vipMoney;
  343. }else{
  344. price = res[0].money;
  345. }
  346. this.price = price;
  347. this.priceIndex = 0;
  348. req.setStorage('actPrice',price)
  349. resolve();
  350. })
  351. })
  352. },
  353. getuserVip() {
  354. return new Promise((resolve,reject)=>{
  355. req.getRequest('/api/user/levelDetails', {}, data => {
  356. let expireTime = Array;
  357. if (data.expireTime) {
  358. expireTime = data.expireTime.split(" ");
  359. data.expireTime = data.expireTime.replace(/-/g, '/');
  360. } // 解决苹果不兼容---日期
  361. let nowTime = new Date().getTime();
  362. let endTime = new Date(data.expireTime).getTime();
  363. let times = parseInt((endTime - nowTime) / 1000); // var expireTime= new Date(data.expireTime)
  364. // console.log(times, nowTime, endTime, data.expireTime);
  365. this.userinfovip = data;
  366. if (times <= 0) {
  367. this.userinfovip.end = true;
  368. } else {
  369. this.userinfovip.end = false;
  370. }
  371. });
  372. resolve();
  373. })
  374. },
  375. getBrowse(){
  376. let params={
  377. behavior: 4,
  378. type: 2,
  379. bindId: this.options.id,
  380. }
  381. req.saveBehavior(params, data => {});
  382. },
  383. toActivity(item){
  384. uni.navigateTo({
  385. url: '/match/activityDetail/activityDetail?id=' + item.id
  386. })
  387. },
  388. choose: function () {
  389. let freshen = false;
  390. this.$emit('freshen', {
  391. detail: freshen
  392. });
  393. },
  394. clickCollect(){
  395. req.isLogin().then(success => {
  396. if(success){
  397. let params={
  398. behavior: 2,
  399. type: 2,
  400. bindId: this.options.id,
  401. }
  402. req.saveBehavior(params, data => {
  403. if(this.detail.isCollect) this.detail.collect--;
  404. else this.detail.collect++;
  405. this.detail.isCollect = !this.detail.isCollect;
  406. });
  407. // req.postRequest('/api/collect',this.appId,{
  408. // bindId: this.detail.id,
  409. // type: 2
  410. // },res=>{
  411. // this.detail.isCollect = !this.detail.isCollect;
  412. // })
  413. }
  414. })
  415. },
  416. showPop(){
  417. let that = this;
  418. if(!req.isLogins(true)) return false;
  419. console.log('that.priceList.length-',that.priceList.length)
  420. if(that.priceList && that.priceList.length == 1){
  421. that.priceList.map(it=>{
  422. if(!it.title){
  423. let price = 0;
  424. if(that.userinfovip.levelGrade>0&& !that.userinfovip.end){
  425. price = it.vipMoney;
  426. }else{
  427. price = it.money;
  428. }
  429. req.setStorage('actPrice',price)
  430. that.jumpUrl('/match/sign/sign?id=' + that.detail.id + '&priceId=' + it.id);
  431. }else{
  432. that.popShow = true;
  433. }
  434. })
  435. }else{
  436. this.popShow = true;
  437. }
  438. },
  439. hidePop(){
  440. this.popShow = false;
  441. },
  442. selProject(it,idx){
  443. if(this.priceIndex == idx) return false;
  444. this.priceIndex = idx;
  445. this.priceId = it.id;
  446. this.personCount = it.personCount;
  447. console.log('priceId==' + this.priceId)
  448. let price = 0;
  449. if(this.userinfovip.levelGrade>0&& !this.userinfovip.end){
  450. price = it.vipMoney;
  451. }else{
  452. price = it.money;
  453. }
  454. this.price = price;
  455. req.setStorage('actPrice',price)
  456. },
  457. jumpUrl(url){
  458. req.isLogin().then(success => {
  459. if(success){
  460. uni.navigateTo({
  461. url: url
  462. })
  463. }
  464. })
  465. this.hidePop();
  466. },
  467. showShare() {
  468. // console.log(11111,this.hideShare)
  469. // #ifdef H5
  470. this.hideShare = false;
  471. this.showSharePop();
  472. console.log('引导分享==')
  473. // #endif
  474. // #ifndef H5
  475. req.isLogin().then(success => {
  476. // console.log(success)
  477. if (success) {
  478. this.getCodeUrl()
  479. this.setData({
  480. hideShare: false
  481. });
  482. // console.log(this.hideShare)
  483. }
  484. });
  485. // #endif
  486. },
  487. getCodeUrl() {
  488. let that = this;
  489. let scene = that.detail.id;
  490. // console.log(scene); //获取小程序码
  491. const params = {
  492. page: 'match/activityDetail/activityDetail',
  493. scene: scene
  494. };
  495. req.getRequest('/api/program/codev', params, url => {
  496. that.setData({
  497. codeUrl: url
  498. });
  499. });
  500. },
  501. click(e) {
  502. // console.log(e,"7899")
  503. this.hideShare = e
  504. },
  505. loadCodeParams() {
  506. let _ts = this;
  507. return new Promise((resolve, reject) => {
  508. let form = {
  509. scene: _ts.options.scene?_ts.options.scene:_ts.options.x_code_id
  510. };
  511. if (!_ts.options.scene && !_ts.options.x_code_id) {
  512. resolve();
  513. return false;
  514. }
  515. req.getRequest('/api/code/params', form, data => {
  516. if(_ts.options.x_code_id){
  517. let res = JSON.parse(data.scene)
  518. for(let key in res){
  519. this.options[key] = res[key]
  520. }
  521. resolve();
  522. }else{
  523. let res = data.scene.split('_');
  524. this.options.id = res[0];
  525. req.setStorage('pidCode', data.userId);
  526. resolve();
  527. }
  528. });
  529. });
  530. },
  531. saveShareBehavior(){
  532. let params={
  533. behavior: 6,
  534. type: 2,
  535. bindId: this.options.id,
  536. }
  537. req.saveBehavior(params, data => {});
  538. },
  539. }
  540. };
  541. </script>
  542. <style>page{background: #fff;}</style>
  543. <style>
  544. @import "./activityDetail.css";
  545. </style>