activityDetail.vue 10 KB

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