activityDetail.vue 13 KB

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