activityDetail.vue 13 KB

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