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.browse}} 收藏 69</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="true" @click="jumpUrl('/businessAssociation/associationIndex/associationIndex?id='+detail.associationId)">
  35. <view class="ddflex">
  36. <image src="/static/images/lj_img.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;">杜平</view>
  39. <view style="margin-top: 3rpx;" class="ddflex">
  40. <view class="user-tag">中国人寿湖南</view>
  41. <view class="user-tag">高级组经理</view>
  42. <view class="user-tag">入司10年</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="clickCollect">
  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";
  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.getBrowse();
  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. showPop(){
  310. let that = this;
  311. console.log('that.priceList.length-',that.priceList.length)
  312. if(that.priceList && that.priceList.length == 1){
  313. that.priceList.map(it=>{
  314. if(!it.title){
  315. let price = 0;
  316. if(that.userinfovip.levelGrade>0&& !that.userinfovip.end){
  317. price = it.vipMoney;
  318. }else{
  319. price = it.money;
  320. }
  321. req.setStorage('actPrice',price)
  322. that.jumpUrl('/match/sign/sign?id=' + that.detail.id + '&priceId=' + it.id);
  323. }else{
  324. that.popShow = true;
  325. }
  326. })
  327. }else{
  328. this.popShow = true;
  329. }
  330. },
  331. hidePop(){
  332. this.popShow = false;
  333. },
  334. selProject(it,idx){
  335. if(this.priceIndex == idx) return false;
  336. this.priceIndex = idx;
  337. this.priceId = it.id;
  338. console.log('priceId==' + this.priceId)
  339. let price = 0;
  340. if(this.userinfovip.levelGrade>0&& !this.userinfovip.end){
  341. price = it.vipMoney;
  342. }else{
  343. price = it.money;
  344. }
  345. this.price = price;
  346. req.setStorage('actPrice',price)
  347. },
  348. jumpUrl(url){
  349. req.isLogin().then(success => {
  350. if(success){
  351. uni.navigateTo({
  352. url: url
  353. })
  354. }
  355. })
  356. this.hidePop();
  357. },
  358. showShare() {
  359. // console.log(11111,this.hideShare)
  360. // #ifdef H5
  361. this.setData({
  362. hideShare: false
  363. });
  364. // #endif
  365. // #ifndef H5
  366. req.isLogin().then(success => {
  367. // console.log(success)
  368. if (success) {
  369. this.getCodeUrl()
  370. this.setData({
  371. hideShare: false
  372. });
  373. // console.log(this.hideShare)
  374. }
  375. });
  376. // #endif
  377. },
  378. getCodeUrl() {
  379. let that = this;
  380. let scene = that.detail.id;
  381. // console.log(scene); //获取小程序码
  382. const params = {
  383. page: 'match/activityDetail/activityDetail',
  384. scene: scene
  385. };
  386. req.getRequest('/api/program/codev', params, url => {
  387. that.setData({
  388. codeUrl: url
  389. });
  390. });
  391. },
  392. click(e) {
  393. // console.log(e,"7899")
  394. this.hideShare = e
  395. },
  396. loadCodeParams() {
  397. let _ts = this;
  398. return new Promise((resolve, reject) => {
  399. let form = {
  400. scene: _ts.options.scene
  401. };
  402. if (!_ts.options.scene) {
  403. resolve();
  404. return false;
  405. }
  406. req.getRequest('/api/code/params', form, data => {
  407. let res = data.scene.split('_');
  408. this.options.id = res[0];
  409. req.setStorage('pidCode', data.userId);
  410. resolve();
  411. });
  412. });
  413. },
  414. }
  415. };
  416. </script>
  417. <style>
  418. @import "./activityDetail.css";
  419. </style>