activityDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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. };
  142. },
  143. async onLoad(options) {
  144. uni.showShareMenu({
  145. withShareTicket: true,
  146. menus: ['shareAppMessage', 'shareTimeline']
  147. });
  148. this.options = options;
  149. if(options.shareId) req.setStorage('shareId',options.shareId)
  150. // req.silenceLogin(options.userId, '');
  151. // 朋友圈页面不调用登陆
  152. if(!this.options.isSharePYQ){
  153. await req.silenceLogin(options.userId, '');
  154. setTimeout(()=>{
  155. this.getUpdate()
  156. },500)
  157. }
  158. },
  159. async onShow() {
  160. // this.isLogin = req.isAuth();
  161. // await this.loadCodeParams();
  162. if(!this.options.isSharePYQ){
  163. await req.silenceLogin(this.options.userId, '');
  164. }
  165. if(this.options.scene)
  166. this.options.id = this.options.scene
  167. await this.getConfig();
  168. await this.getData(true);
  169. if(this.isLogin){
  170. // await this.getuserVip();
  171. }
  172. this.userBehavior(4);
  173. await this.getPrice();
  174. },
  175. onReachBottom: function() {
  176. },
  177. onShareAppMessage: function() {
  178. let url = '/match/activityDetail/activityDetail?id=' + this.detail.id
  179. if(req.getStorage('userInfo')){
  180. url += '&userId=' + req.getStorage('userInfo').id
  181. }
  182. if(req.getStorage('userInfo').userType==1){
  183. url += '&shareId=' + req.getStorage('userInfo').saleNo
  184. }
  185. req.saveBehaviorNew(this.detail.id,2,6)
  186. return {
  187. title: this.detail.title,
  188. imageUrl: this.detail.pic,
  189. path: url
  190. };
  191. },
  192. onShareTimeline() {
  193. req.saveBehaviorNew(this.detail.id,2,6)
  194. return {
  195. title: this.detail.title,
  196. imageUrl: this.detail.pic,
  197. path: '/match/activityDetail/activityDetail',
  198. query:'id=' + this.detail.id+'&isSharePYQ=' + true +'&isShare=' + true+(req.getStorage('userInfo').userType==1?('&shareId='+req.getStorage('userInfo').saleNo):'')
  199. };
  200. },
  201. methods: {
  202. getConfig() {
  203. var _this = this;
  204. return new Promise((resolve, reject) => {
  205. req.getRequest('/api/other/config', {}, function(res) {
  206. _this.about = res;
  207. _this.getSystem();
  208. resolve();
  209. });
  210. });
  211. },
  212. getSystem(){
  213. if(uni.getSystemInfoSync().platform == 'ios'){
  214. if(this.about.is_open_iosPay == 1){
  215. this.isIos = false;
  216. }else{
  217. this.isIos = true;
  218. }
  219. }else{
  220. this.isIos = false;
  221. }
  222. },
  223. openMap(){
  224. let that = this;
  225. console.log('打开地图')
  226. uni.openLocation({
  227. latitude: Number(that.detail.lat),
  228. longitude: Number(that.detail.lng),
  229. address: that.detail.address,
  230. success: function () {
  231. console.log('success');
  232. },
  233. fail(res){
  234. console.log('fail=='+JSON.stringify(res))
  235. }
  236. })
  237. },
  238. getData(isShow){
  239. return new Promise((resolve, reject) => {
  240. req.getRequest('/api/match/detail',{id: this.options.id},res => {
  241. this.detail = res;
  242. this.isShow = true;
  243. resolve();
  244. },isShow);
  245. })
  246. },
  247. getPrice(){
  248. return new Promise((resolve, reject) => {
  249. req.getRequest('/api/match/price',{id: this.options.id},res=>{
  250. this.priceList = res;
  251. this.priceId = res[0].id;
  252. let price = 0;
  253. if(this.userinfovip.levelGrade>0&& !this.userinfovip.end){
  254. price = res[0].vipMoney;
  255. }else{
  256. price = res[0].money;
  257. }
  258. this.price = price;
  259. req.setStorage('actPrice',price)
  260. resolve();
  261. })
  262. })
  263. },
  264. getuserVip() {
  265. return new Promise((resolve,reject)=>{
  266. req.getRequest('/api/user/levelDetails', {}, data => {
  267. let expireTime = Array;
  268. if (data.expireTime) {
  269. expireTime = data.expireTime.split(" ");
  270. data.expireTime = data.expireTime.replace(/-/g, '/');
  271. } // 解决苹果不兼容---日期
  272. let nowTime = new Date().getTime();
  273. let endTime = new Date(data.expireTime).getTime();
  274. let times = parseInt((endTime - nowTime) / 1000); // var expireTime= new Date(data.expireTime)
  275. // console.log(times, nowTime, endTime, data.expireTime);
  276. this.userinfovip = data;
  277. if (times <= 0) {
  278. this.userinfovip.end = true;
  279. } else {
  280. this.userinfovip.end = false;
  281. }
  282. });
  283. resolve();
  284. })
  285. },
  286. formatTimeCommStr(dataStr) {
  287. return util.formatTimeCommStr(dataStr, 'M/D 00:00');
  288. },
  289. formData(validDate){
  290. let time = new Date(validDate.replace(/-/g, '/'));
  291. return util.formatTime(time).t2
  292. },
  293. formDataObj(validDate){
  294. let time = new Date(validDate.replace(/-/g, '/'));
  295. return util.formatTime(time)
  296. },
  297. formDatahd(){
  298. if(this.detail.startTime&&this.detail.endTime){}
  299. else return false
  300. return this.formDataObj(this.detail.startTime).t2==this.formDataObj(this.detail.endTime).t2?
  301. (this.formDataObj(this.detail.startTime).t2+' '+this.formDataObj(this.detail.startTime).t6+' - '+this.formDataObj(this.detail.endTime).t6)
  302. :(this.formDataObj(this.detail.startTime).t5+' - '+this.formDataObj(this.detail.endTime).t5)
  303. },
  304. getBrowse(){
  305. let params={
  306. bindId: this.options.id,
  307. type: 10
  308. }
  309. req.postRequest('/api/browse', params, data => {});
  310. },
  311. toActivity(item){
  312. uni.navigateTo({
  313. url: '/match/activityDetail/activityDetail?id=' + item.id
  314. })
  315. },
  316. choose: function () {
  317. let freshen = false;
  318. this.$emit('freshen', {
  319. detail: freshen
  320. });
  321. },
  322. // clickCollect(){
  323. // req.isLogin().then(success => {
  324. // if(success){
  325. // req.postRequest('/api/collect',{
  326. // bindId: this.detail.id,
  327. // type: 2
  328. // },res=>{
  329. // this.detail.isCollect = !this.detail.isCollect;
  330. // })
  331. // }
  332. // })
  333. // },
  334. // 用户行为
  335. userBehavior(type) {
  336. var dataP = {};
  337. dataP.type =2 //、产品 2、活动 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 12、用户须知 13、素材 15、医院科室 16、海报 20、医生 21 新闻 23名片
  338. dataP.behavior = type; //1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、分享
  339. dataP.bindId = this.detail.id;
  340. req.postRequestLoding('/api/v3/behavior/save', dataP, data => {
  341. if (type == 2) {
  342. this.detail.isCollect = !this.detail.isCollect;
  343. if(this.detail.isCollect){
  344. req.saveBehaviorNew(this.detail.id,2,2)
  345. }else{
  346. req.saveBehaviorNew(this.detail.id,2,16)
  347. }
  348. }
  349. if (type == 3) {
  350. this.cardInfo.follow = !this.cardInfo.follow
  351. }
  352. if(type == 4) {
  353. req.saveBehaviorNew(this.detail.id,2,4)
  354. }
  355. });
  356. },
  357. showPop(){
  358. let that = this;
  359. that.jumpUrl('/match/sign/sign?id=' + that.detail.id);
  360. },
  361. hidePop(){
  362. this.popShow = false;
  363. },
  364. selProject(it,idx){
  365. if(this.priceIndex == idx) return false;
  366. this.priceIndex = idx;
  367. this.priceId = it.id;
  368. console.log('priceId==' + this.priceId)
  369. let price = 0;
  370. if(this.userinfovip.levelGrade>0&& !this.userinfovip.end){
  371. price = it.vipMoney;
  372. }else{
  373. price = it.money;
  374. }
  375. this.price = price;
  376. req.setStorage('actPrice',price)
  377. },
  378. jumpUrl(url){
  379. req.isLogin().then(success => {
  380. if(success){
  381. uni.navigateTo({
  382. url: url
  383. })
  384. }
  385. })
  386. this.hidePop();
  387. },
  388. showShare() {
  389. // console.log(11111,this.hideShare)
  390. // #ifdef H5
  391. this.setData({
  392. hideShare: false
  393. });
  394. // #endif
  395. // #ifndef H5
  396. req.isLogin().then(success => {
  397. // console.log(success)
  398. if (success) {
  399. this.getCodeUrl()
  400. this.setData({
  401. hideShare: false
  402. });
  403. // console.log(this.hideShare)
  404. }
  405. });
  406. // #endif
  407. },
  408. getCodeUrl() {
  409. let that = this;
  410. let scene = that.detail.id;
  411. // console.log(scene); //获取小程序码
  412. const params = {
  413. page: 'match/activityDetail/activityDetail',
  414. scene: scene
  415. };
  416. req.getRequest('/api/program/codev', params, url => {
  417. that.setData({
  418. codeUrl: url
  419. });
  420. });
  421. },
  422. click(e) {
  423. // console.log(e,"7899")
  424. this.hideShare = e
  425. },
  426. loadCodeParams() {
  427. let _ts = this;
  428. return new Promise((resolve, reject) => {
  429. let form = {
  430. scene: _ts.options.scene
  431. };
  432. if (!_ts.options.scene) {
  433. resolve();
  434. return false;
  435. }
  436. req.getRequest('/api/code/params', form, data => {
  437. let res = data.scene.split('_');
  438. this.options.id = res[0];
  439. req.setStorage('pidCode', data.userId);
  440. resolve();
  441. });
  442. });
  443. },
  444. monthDayDiff(date){
  445. return util.monthDayDiff(date)
  446. },
  447. closeUpdate(){
  448. this.isShowUpdate = false
  449. },
  450. updateInfo(e){
  451. this.isUpdateInfo = e;
  452. },
  453. updateMobile(e){
  454. this.isUpdateMobile = e;
  455. },
  456. getUpdate() {
  457. console.log('getUpdate')
  458. let userInfos = req.getStorage('userInfo')
  459. // if ((!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || !userInfos.nickName || userInfos.nickName.indexOf('用户') > -1) ) {
  460. // console.log('没有昵称')
  461. // this.isShowUpdate = true;
  462. // this.isUpdateInfo = true;
  463. // return false;
  464. // }
  465. if(!userInfos.mobile){
  466. console.log('没有手机号')
  467. this.isShowUpdate = true
  468. this.isUpdateMobile = true
  469. return false;
  470. }
  471. return true;
  472. },
  473. }
  474. };
  475. </script>
  476. <style>
  477. @import "./activityDetail.css";
  478. </style>