activityDetail.vue 13 KB

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