activityDetail.vue 13 KB

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