activityDetail.vue 13 KB

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