activityDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view v-if="isShow">
  3. <view class="top">
  4. <view v-if="detail.imageList.length>0">
  5. <swiper autoplay="true"
  6. circular="true" duration="1000" class="act-img">
  7. <block v-for="(item, index) in detail.imageList" :key="index">
  8. <swiper-item autoplay="true">
  9. <image class="act-img" lazy-load="true" :src="item.url"
  10. mode="aspectFill"></image>
  11. </swiper-item>
  12. </block>
  13. </swiper>
  14. </view>
  15. <image :src="detail.pic" mode="aspectFill" class="act-img" v-else></image>
  16. <view class="title">{{detail.title}}</view>
  17. <view class="datas">浏览 {{detail.popularity}} 收藏 {{detail.collect}}</view>
  18. <view class="baoming-box">
  19. <view class="ddflex">
  20. <image src="../static/images/bmsj.png"></image>
  21. <text>报名时间</text>
  22. </view>
  23. <view class="baoming-time">{{formData(detail.enlistStartTime)}} 至 {{formData(detail.enlistEndTime)}}</view>
  24. <view class="ddflex" style="margin-top: 25rpx;">
  25. <image src="../static/images/bmfy.png" style="visibility: hidden;"></image>
  26. <text>活动时间</text>
  27. </view>
  28. <view class="baoming-time">
  29. {{formData(detail.startTime)}} 至 {{formData(detail.endTime)}}
  30. </view>
  31. </view>
  32. <view class="hddz-box" style="margin-top: 26rpx;" v-if="detail.address">
  33. <view class="ddflex">
  34. <image src="../static/images/hddz.png"></image>
  35. <text>活动地点</text>
  36. </view>
  37. <!-- v-if="detail.address" -->
  38. <view class="ddflex hddz-area" @click="openMap()">
  39. <view class="fflex tover">{{detail.address}}</view>
  40. <image src="../static/images/crico2.png" class="rico"></image>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="date">
  45. <view class="datass ddflex" style="justify-content: space-between;" v-if="detail.card" @click="jumpUrl('/card/index/index?id='+detail.card.id)">
  46. <view class="ddflex">
  47. <image :src="detail.card.avatar?detail.card.avatar:'../../static/pages/images/userimg.png'" style="width:66rpx ;height: 66rpx;border-radius: 100%;" mode="aspectFill" class="dimg"></image>
  48. <view>
  49. <view style="font-size: 28rpx;font-weight: bold;color: #333333;line-height: 40rpx;">{{detail.card.realName}}</view>
  50. <view style="margin-top: 3rpx;" class="ddflex">
  51. <view class="user-tag">{{detail.card.companyName}}</view>
  52. <view class="user-tag">{{detail.card.jobName}}</view>
  53. <view class="user-tag">入司{{detail.card.inDate?monthDayDiff(detail.card.inDate):'1年'}}</view>
  54. </view>
  55. </view>
  56. </view>
  57. <image src="../static/images/crico2.png" class="rico"></image>
  58. </view>
  59. </view>
  60. <view class="det">
  61. <view class="tit ddflex">活动介绍<!-- <image src="../../static/pages/images/crico1.png" class="rico"></image> --></view>
  62. <view class="content">
  63. <mp-html :content="detail.text" :lazy-load="true" @imgtap="choose"></mp-html>
  64. </view>
  65. </view>
  66. <view class="savepadding"></view>
  67. <view class="bot fixed bgfff">
  68. <view class="savepadding ddflex" style="justify-content: space-between;">
  69. <view class="btnfot ddflex">
  70. <navigator class="botbtn" open-type="switchTab" url="/pages/index/index" hover-class="none">
  71. <image src="/static/pages/images/sy.png"></image>主页
  72. </navigator>
  73. <view class="botbtn" @tap="userBehavior(2)">
  74. <image src="/static/pages/images/shoucang_h.png" v-if="detail.isCollect"></image>
  75. <image src="/static/pages/images/shoucang.png" v-else></image>收藏
  76. </view>
  77. <view class="botbtn" @click="showShare"><image src="../static/images/fxico1_1.png"></image>分享</view>
  78. <!-- <button open-type="share" class="botbtn">
  79. <image src="../../static/pages/images/fxico1_1.png"></image>分享
  80. </button> -->
  81. </view>
  82. <view class="btns ddflex">
  83. <view class="btn" @click="jumpUrl('/match/activity/activity')" v-if="detail.isEnlist">查看报名</view>
  84. <block v-else>
  85. <view class="btn" @click="showPop()" v-if="detail.state == 2">立即报名</view>
  86. <view class="btn" v-if="detail.state == 3">报名结束</view>
  87. <view class="btn" v-if="detail.state == 4">活动中</view>
  88. <view class="btn end" v-if="detail.state == 5">活动结束</view>
  89. </block>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="ceng" v-if="popShow" @click="hidePop()"></view>
  94. <view class="popup" v-if="popShow">
  95. <image src="../../static/pages/images/clear.png" class="close" @click="hidePop()"></image>
  96. <view class="p-title">{{detail.title}}</view>
  97. <view class="p-bri tovers">{{detail.brief}}</view>
  98. <view class="money free"><text>¥</text>{{price}}</view>
  99. <view class="pop-tit">报名项目</view>
  100. <view class="pop-con">
  101. <view class="p-list ddflex">
  102. <view :class="'li' + (priceIndex == index ? ' active' : '')" v-for="(item,index) in priceList" :key="index" @click="selProject(item,index)">{{item.title}}</view>
  103. </view>
  104. </view>
  105. <view class="pop-btn" @click="jumpUrl('/match/sign/sign?id=' + detail.id + '&priceId=' + priceId)">马上报名</view>
  106. </view>
  107. <v-share :hide-toast="hideShare" :product="detail" :code-url="codeUrl" @onFather="click"></v-share>
  108. <update-userinfonew :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate" @closeUpdate="closeUpdate" @updateInfo="updateInfo" @updateMobile="updateMobile"></update-userinfonew>
  109. </view>
  110. </template>
  111. <script>
  112. const req = require('../../utils/request.js');
  113. const api = require('../../utils/api.js');
  114. const util = require('../../utils/util.js');
  115. const app = getApp();
  116. import mpHtml from "../../components/mp-html/components/mp-html/mp-html";
  117. import vShare from "../components/share-activity/share.vue";
  118. export default {
  119. components: {
  120. mpHtml,
  121. vShare
  122. },
  123. data() {
  124. return {
  125. isShow: false,
  126. options: {},
  127. detail: {},
  128. isLogin: false,
  129. userinfovip: {},
  130. isIos: false,
  131. priceIndex: 0,
  132. priceList: [],
  133. popShow: false,
  134. priceId: '',
  135. price: 0,
  136. hideShare: true,
  137. codeUrl: '',
  138. isShowUpdate: false, //是否显示更新信息弹窗
  139. isUpdateInfo: false,//更新用户信息
  140. isUpdateMobile: false,//绑定手机号
  141. enterTime : '',//进入页面时间
  142. outTime : '',//页面卸载时间
  143. stayTime : 0//页面停留时间
  144. };
  145. },
  146. async onLoad(options) {
  147. uni.showShareMenu({
  148. withShareTicket: true,
  149. menus: ['shareAppMessage', 'shareTimeline']
  150. });
  151. this.options = options;
  152. if(options.shareId) req.setStorage('shareId',options.shareId)
  153. // req.silenceLogin(options.userId, '');
  154. // 朋友圈页面不调用登陆
  155. if(!this.options.isSharePYQ){
  156. await req.silenceLogin(options.userId, '');
  157. setTimeout(()=>{
  158. this.getUpdate()
  159. },500)
  160. }
  161. },
  162. async onShow() {
  163. this.enterTime = new Date();
  164. console.log('---用户进入时间---',this.enterTime);
  165. // this.isLogin = req.isAuth();
  166. // await this.loadCodeParams();
  167. if(!this.options.isSharePYQ){
  168. await req.silenceLogin(this.options.userId, '');
  169. }
  170. if(this.options.scene)
  171. this.options.id = this.options.scene
  172. await this.getConfig();
  173. await this.getData(true);
  174. if(this.isLogin){
  175. // await this.getuserVip();
  176. }
  177. this.userBehavior(4);
  178. await this.getPrice();
  179. },
  180. onHide(){
  181. // 用户退出时间
  182. this.outTime = new Date();
  183. //停留时间(毫秒)
  184. this.stayTime = (this.outTime.getTime() - this.enterTime.getTime());
  185. console.log('---用户浏览---',Math.ceil(this.stayTime/1000))
  186. req.saveBehaviorNew(this.detail.id,2,4,'','',this.options.userId,Math.ceil(this.stayTime/1000))
  187. },
  188. onUnload(){
  189. // 用户退出时间
  190. this.outTime = new Date();
  191. //停留时间(毫秒)
  192. this.stayTime = (this.outTime.getTime() - this.enterTime.getTime());
  193. console.log('---用户浏览总时长---',Math.ceil(this.stayTime/1000))
  194. req.saveBehaviorNew(this.detail.id,2,4,'','',this.options.userId,Math.ceil(this.stayTime/1000))
  195. },
  196. onReachBottom: function() {
  197. },
  198. onShareAppMessage: function() {
  199. let url = '/match/activityDetail/activityDetail?id=' + this.detail.id
  200. if(req.getStorage('userInfo')){
  201. url += '&userId=' + req.getStorage('userInfo').id
  202. }
  203. if(req.getStorage('userInfo').userType==1){
  204. url += '&shareId=' + req.getStorage('userInfo').saleNo
  205. }
  206. req.saveBehaviorNew(this.detail.id,2,6)
  207. return {
  208. title: this.detail.title,
  209. imageUrl: this.detail.pic,
  210. path: url
  211. };
  212. },
  213. onShareTimeline() {
  214. req.saveBehaviorNew(this.detail.id,2,6)
  215. return {
  216. title: this.detail.title,
  217. imageUrl: this.detail.pic,
  218. path: '/match/activityDetail/activityDetail',
  219. query:'id=' + this.detail.id+'&isSharePYQ=' + true +'&isShare=' + true+(req.getStorage('userInfo').userType==1?('&shareId='+req.getStorage('userInfo').saleNo):'')
  220. };
  221. },
  222. methods: {
  223. getConfig() {
  224. var _this = this;
  225. return new Promise((resolve, reject) => {
  226. req.getRequest('/api/other/config', {}, function(res) {
  227. _this.about = res;
  228. _this.getSystem();
  229. resolve();
  230. });
  231. });
  232. },
  233. getSystem(){
  234. if(uni.getSystemInfoSync().platform == 'ios'){
  235. if(this.about.is_open_iosPay == 1){
  236. this.isIos = false;
  237. }else{
  238. this.isIos = true;
  239. }
  240. }else{
  241. this.isIos = false;
  242. }
  243. },
  244. openMap(){
  245. let that = this;
  246. console.log('打开地图')
  247. uni.openLocation({
  248. latitude: Number(that.detail.lat),
  249. longitude: Number(that.detail.lng),
  250. address: that.detail.address,
  251. success: function () {
  252. console.log('success');
  253. },
  254. fail(res){
  255. console.log('fail=='+JSON.stringify(res))
  256. }
  257. })
  258. },
  259. getData(isShow){
  260. return new Promise((resolve, reject) => {
  261. req.getRequest('/api/match/detail',{id: this.options.id},res => {
  262. this.detail = res;
  263. this.isShow = true;
  264. resolve();
  265. },isShow);
  266. })
  267. },
  268. getPrice(){
  269. return new Promise((resolve, reject) => {
  270. req.getRequest('/api/match/price',{id: this.options.id},res=>{
  271. this.priceList = res;
  272. this.priceId = res[0].id;
  273. let price = 0;
  274. if(this.userinfovip.levelGrade>0&& !this.userinfovip.end){
  275. price = res[0].vipMoney;
  276. }else{
  277. price = res[0].money;
  278. }
  279. this.price = price;
  280. req.setStorage('actPrice',price)
  281. resolve();
  282. })
  283. })
  284. },
  285. getuserVip() {
  286. return new Promise((resolve,reject)=>{
  287. req.getRequest('/api/user/levelDetails', {}, data => {
  288. let expireTime = Array;
  289. if (data.expireTime) {
  290. expireTime = data.expireTime.split(" ");
  291. data.expireTime = data.expireTime.replace(/-/g, '/');
  292. } // 解决苹果不兼容---日期
  293. let nowTime = new Date().getTime();
  294. let endTime = new Date(data.expireTime).getTime();
  295. let times = parseInt((endTime - nowTime) / 1000); // var expireTime= new Date(data.expireTime)
  296. // console.log(times, nowTime, endTime, data.expireTime);
  297. this.userinfovip = data;
  298. if (times <= 0) {
  299. this.userinfovip.end = true;
  300. } else {
  301. this.userinfovip.end = false;
  302. }
  303. });
  304. resolve();
  305. })
  306. },
  307. formatTimeCommStr(dataStr) {
  308. return util.formatTimeCommStr(dataStr, 'M/D 00:00');
  309. },
  310. formData(validDate){
  311. let time = new Date(validDate.replace(/-/g, '/'));
  312. return util.formatTime(time).t2
  313. },
  314. formDataObj(validDate){
  315. let time = new Date(validDate.replace(/-/g, '/'));
  316. return util.formatTime(time)
  317. },
  318. formDatahd(){
  319. if(this.detail.startTime&&this.detail.endTime){}
  320. else return false
  321. return this.formDataObj(this.detail.startTime).t2==this.formDataObj(this.detail.endTime).t2?
  322. (this.formDataObj(this.detail.startTime).t2+' '+this.formDataObj(this.detail.startTime).t6+' - '+this.formDataObj(this.detail.endTime).t6)
  323. :(this.formDataObj(this.detail.startTime).t5+' - '+this.formDataObj(this.detail.endTime).t5)
  324. },
  325. getBrowse(){
  326. let params={
  327. bindId: this.options.id,
  328. type: 10
  329. }
  330. req.postRequest('/api/browse', params, data => {});
  331. },
  332. toActivity(item){
  333. uni.navigateTo({
  334. url: '/match/activityDetail/activityDetail?id=' + item.id
  335. })
  336. },
  337. choose: function () {
  338. let freshen = false;
  339. this.$emit('freshen', {
  340. detail: freshen
  341. });
  342. },
  343. // clickCollect(){
  344. // req.isLogin().then(success => {
  345. // if(success){
  346. // req.postRequest('/api/collect',{
  347. // bindId: this.detail.id,
  348. // type: 2
  349. // },res=>{
  350. // this.detail.isCollect = !this.detail.isCollect;
  351. // })
  352. // }
  353. // })
  354. // },
  355. // 用户行为
  356. userBehavior(type) {
  357. var dataP = {};
  358. dataP.type =2 //、产品 2、活动 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 12、用户须知 13、素材 15、医院科室 16、海报 20、医生 21 新闻 23名片
  359. dataP.behavior = type; //1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、分享
  360. dataP.bindId = this.detail.id;
  361. req.postRequestLoding('/api/v3/behavior/save', dataP, data => {
  362. if (type == 2) {
  363. this.detail.isCollect = !this.detail.isCollect;
  364. if(this.detail.isCollect){
  365. req.saveBehaviorNew(this.detail.id,2,2)
  366. }else{
  367. req.saveBehaviorNew(this.detail.id,2,16)
  368. }
  369. }
  370. if (type == 3) {
  371. this.cardInfo.follow = !this.cardInfo.follow
  372. }
  373. if(type == 4) {
  374. // req.saveBehaviorNew(this.detail.id,2,4)
  375. }
  376. });
  377. },
  378. showPop(){
  379. let that = this;
  380. that.jumpUrl('/match/sign/sign?id=' + that.detail.id);
  381. },
  382. hidePop(){
  383. this.popShow = false;
  384. },
  385. selProject(it,idx){
  386. if(this.priceIndex == idx) return false;
  387. this.priceIndex = idx;
  388. this.priceId = it.id;
  389. console.log('priceId==' + this.priceId)
  390. let price = 0;
  391. if(this.userinfovip.levelGrade>0&& !this.userinfovip.end){
  392. price = it.vipMoney;
  393. }else{
  394. price = it.money;
  395. }
  396. this.price = price;
  397. req.setStorage('actPrice',price)
  398. },
  399. jumpUrl(url){
  400. req.isLogin().then(success => {
  401. if(success){
  402. uni.navigateTo({
  403. url: url
  404. })
  405. }
  406. })
  407. this.hidePop();
  408. },
  409. showShare() {
  410. // console.log(11111,this.hideShare)
  411. // #ifdef H5
  412. this.setData({
  413. hideShare: false
  414. });
  415. // #endif
  416. // #ifndef H5
  417. req.isLogin().then(success => {
  418. // console.log(success)
  419. if (success) {
  420. this.getCodeUrl()
  421. this.setData({
  422. hideShare: false
  423. });
  424. // console.log(this.hideShare)
  425. }
  426. });
  427. // #endif
  428. },
  429. getCodeUrl() {
  430. let that = this;
  431. let scene = that.detail.id;
  432. // console.log(scene); //获取小程序码
  433. const params = {
  434. page: 'match/activityDetail/activityDetail',
  435. scene: scene
  436. };
  437. req.getRequest('/api/program/codev', params, url => {
  438. that.setData({
  439. codeUrl: url
  440. });
  441. });
  442. },
  443. click(e) {
  444. // console.log(e,"7899")
  445. this.hideShare = e
  446. },
  447. loadCodeParams() {
  448. let _ts = this;
  449. return new Promise((resolve, reject) => {
  450. let form = {
  451. scene: _ts.options.scene
  452. };
  453. if (!_ts.options.scene) {
  454. resolve();
  455. return false;
  456. }
  457. req.getRequest('/api/code/params', form, data => {
  458. let res = data.scene.split('_');
  459. this.options.id = res[0];
  460. req.setStorage('pidCode', data.userId);
  461. resolve();
  462. });
  463. });
  464. },
  465. monthDayDiff(date){
  466. return util.monthDayDiff(date)
  467. },
  468. closeUpdate(){
  469. this.isShowUpdate = false
  470. },
  471. updateInfo(e){
  472. this.isUpdateInfo = e;
  473. },
  474. updateMobile(e){
  475. this.isUpdateMobile = e;
  476. },
  477. getUpdate() {
  478. console.log('getUpdate')
  479. let userInfos = req.getStorage('userInfo')
  480. // if ((!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || !userInfos.nickName || userInfos.nickName.indexOf('用户') > -1) ) {
  481. // console.log('没有昵称')
  482. // this.isShowUpdate = true;
  483. // this.isUpdateInfo = true;
  484. // return false;
  485. // }
  486. if(!userInfos.mobile){
  487. console.log('没有手机号')
  488. this.isShowUpdate = true
  489. this.isUpdateMobile = true
  490. return false;
  491. }
  492. return true;
  493. },
  494. }
  495. };
  496. </script>
  497. <style>
  498. @import "./activityDetail.css";
  499. </style>