activityDetail.vue 12 KB

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