index.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439
  1. <template>
  2. <!-- 首页 -->
  3. <view class="home">
  4. <view class="banner_main"><image :src="banner.banner_1"></image></view>
  5. <template v-if="!isAuthLogin">
  6. <view class="index_container">
  7. <view class="sign_up_container" @click="signUp(userInfo.type)">
  8. <view class="top">
  9. <text>第{{ userInfo.season ? userInfo.season : '' }}届大卫博士创业{{ userInfo.season_type | activityType }}</text>
  10. </view>
  11. <view class="bottom">
  12. <view class="desc_main">
  13. <view class="bot_parent" v-if="userInfo.province || userInfo.city">举办地址:{{ userInfo.province }} {{ userInfo.city }} {{ userInfo.area }}</view>
  14. <view class="bot_parent">
  15. <text>举办时间:</text>
  16. <text v-if="userInfo.time_start">{{ getTime(userInfo.time_start) }}</text>
  17. <text>-</text>
  18. <text v-if="userInfo.time_end">{{ getTime(userInfo.time_end) }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="surplus signedNum">
  23. <view class="signedNum_item">
  24. <text>已报名:</text>
  25. <text style="color:#FF5432;font-size:32rpx;font-weight:bold">{{ userInfo.count || 0 }}人</text>
  26. </view>
  27. <view class="signedNum_item">
  28. <text>剩余名额:</text>
  29. <text style="color:#FF5432;font-size:32rpx;font-weight:bold">
  30. {{ userInfo.is_limit ? `${Number(userInfo.limit_num || 0) - (userInfo.count || 0)}人` : '不限制' }}
  31. </text>
  32. </view>
  33. </view>
  34. <view class="surplus" v-if="offStart || offEnd">
  35. <text>
  36. <text>距离报名</text>
  37. <text>{{ offStart ? '开始' : '截止' }}</text>
  38. <text>仅剩:</text>
  39. </text>
  40. <text style="color:#FF5432;font-size:32rpx;font-weight:bold">{{ offStart ? offStart : offEnd }}</text>
  41. </view>
  42. <view class="surplus" v-if="!offStart && !offEnd && timeStart">
  43. <text>距离培训开始仅剩:</text>
  44. <text style="color:#FF5432;font-size:32rpx;font-weight:bold">{{ timeStart }}</text>
  45. </view>
  46. <view class="tip_container" :class="offSate ? 'off_line' : 'finish'">{{ offSate ? '火爆开启' : '暂未开启' }}</view>
  47. </view>
  48. <view
  49. class="desc_btn flexCC"
  50. :class="(!offStart && offEnd && limitState) || userInfo.sign_up ? 'offline_btn' : 'no_btn'"
  51. v-if="userInfo.type == 0"
  52. @click="signUp(userInfo.type)"
  53. >
  54. <text v-if="userInfo.sign_up">报名成功</text>
  55. <text v-if="!userInfo.sign_up">{{ !offEnd && !offStart ? '报名截止' : !limitState ? '人数已满' : '立即报名' }}</text>
  56. </view>
  57. <view class="desc_btn look flexCC" v-if="userInfo.type == 1" @click="signUp(userInfo.type)">查看信息</view>
  58. <view class="tab" v-if="userInfo.type == 0 && userRoot">
  59. <view @click="tabSkip(1)" :class="tabType == 1 ? 'active' : ''">
  60. <image src="../../static/imgs/notice.png" mode=""></image>
  61. <text>报名须知</text>
  62. </view>
  63. <view @click="tabSkip(2)" :class="tabType == 2 ? 'active' : ''">
  64. <image src="../../static/imgs/course.png" mode=""></image>
  65. <text>课程介绍</text>
  66. </view>
  67. <view @click="tabSkip(3)" :class="tabType == 3 ? 'active' : ''">
  68. <image src="../../static/imgs/voucher.png" style="width: 35rpx;height:35rpx"></image>
  69. <text>报名凭证</text>
  70. </view>
  71. </view>
  72. <view class="richText ql-snow ql-editor" v-if="tabType == 1 && userInfo.type == 0 && userRoot && userInfo.notice">
  73. <rich-text :nodes="userInfo.notice | formatRichText"></rich-text>
  74. </view>
  75. </view>
  76. <view class="allCount" v-if="userInfo.type == 1" @click="skipList">
  77. <view class="flexB title">
  78. <text>报名管理</text>
  79. <view>
  80. <text>进入详情</text>
  81. <text class="iconfont iconyoujiantou"></text>
  82. </view>
  83. </view>
  84. <view class="flexB count">
  85. <view class="flexCC" style="border-right:1rpx solid #F2F4F5;width:30%;flex-shrink: 0;">
  86. <view>
  87. <text style="font-size:48rpx;">{{ signInfo.apply_num ? signInfo.apply_num : 0 }}</text>
  88. <text>人</text>
  89. </view>
  90. <text style="margin-top:35rpx;">有效报名</text>
  91. </view>
  92. <view class="flexCC">
  93. <view style="color:#EA4A41;">{{ signInfo.no_sign_num ? signInfo.no_sign_num : 0 }}人</view>
  94. <text>未签到</text>
  95. </view>
  96. <view class="flexCC">
  97. <view style="color:#19B766;">{{ signInfo.sign_num ? signInfo.sign_num : 0 }}人</view>
  98. <text>已签到</text>
  99. </view>
  100. <view class="flexCC">
  101. <view style="color:#666;">{{ signInfo.cancel_num ? signInfo.cancel_num : 0 }}人</view>
  102. <text>已退款</text>
  103. </view>
  104. </view>
  105. </view>
  106. <view class="allCount statistics" v-if="userInfo.type == 1" @click="skipData">
  107. <view class="flexB title">
  108. <text>代理数据显示</text>
  109. <view>
  110. <text>进入详情</text>
  111. <text class="iconfont iconyoujiantou"></text>
  112. </view>
  113. </view>
  114. <view class="classify flexB">
  115. <view class="flexCC">
  116. <image src="../../static/imgs/level.png"></image>
  117. <text>等级组成及占比</text>
  118. </view>
  119. <view class="flexCC">
  120. <image src="../../static/imgs/sex.png"></image>
  121. <text>性别组成及占比</text>
  122. </view>
  123. <view class="flexCC">
  124. <image src="../../static/imgs/age.png"></image>
  125. <text>年龄组成及占比</text>
  126. </view>
  127. </view>
  128. </view>
  129. </template>
  130. <template v-else>
  131. <view class="loginText">登录获取活动详情</view>
  132. <button open-type="getUserInfo" @getuserinfo="userLogin" class="loginBtn"></button>
  133. </template>
  134. <!-- <view class="auth_login flexC" v-if="isAuthLogin">
  135. <button open-type="getUserInfo" @getuserinfo="userLogin" class="auth_btn">点击登录</button>
  136. </view> -->
  137. <view class="submit_container" @click.stop="signIn" v-if="userInfo.type == 1">
  138. <view class="sign_up flexC">
  139. <text class="iconfont iconsaoma" style="color:#fff;font-size:55rpx;margin-right:10rpx;"></text>
  140. <text>代理签到</text>
  141. </view>
  142. </view>
  143. <view class="phone_login" v-if="isPhoneLogin">
  144. <view class="phone_container">
  145. <view class="close" @click="isPhoneLogin = false"></view>
  146. <view class="top">
  147. <text>手机号验证</text>
  148. <div class="userImg"><open-data type="userAvatarUrl" class="getImgBtn"></open-data></div>
  149. </view>
  150. <view class="bottom">
  151. <input v-model="phone" type="text" placeholder="请输入手机号" class="input" maxlength="11" />
  152. <view class="bottom_eqcode">
  153. <input v-model="code" type="text" placeholder="输入验证码" class="input eqcode_input" />
  154. <view class="eqcode" @click="getCode">{{ countDown ? `重新获取(${countDown}s)` : '获取验证码' }}</view>
  155. </view>
  156. </view>
  157. <view class="submit_btn" @click="phoneLogin">提交</view>
  158. </view>
  159. </view>
  160. </view>
  161. </template>
  162. <script>
  163. import { wecatLogin, getUserInfo, phoneLogin, sendCode, getBanner, signInfo } from '../../api/index.js';
  164. import { activityType } from "../../utiils/filters.js"
  165. export default {
  166. data() {
  167. return {
  168. timeStart: '', //开始倒计时
  169. limitState: true, //报名人数是否已满 true未满 false已满
  170. tabType: 1, //0 报名须知 1 课程介绍 2报名凭证
  171. title: '', //当前页面标题
  172. userInfo: '', //用户相关信息
  173. offStart: '', //活动开始倒计时
  174. offEnd: '', //活动结束倒计时
  175. offTimer: null, //报名倒计时定时器
  176. startTimer: null, //培训开始倒计时
  177. offSate: true, //是否在活动中 true 是 false 不是
  178. isAuthLogin: false, //是否显示登陆授权按钮 true显示 false不显示
  179. isPhoneLogin: false, //是否显示手机登陆弹窗 true显示 false不显示
  180. wechatInfo: {
  181. latitude: '',
  182. longitude: '',
  183. avatarUrl: '',
  184. nickName: ''
  185. }, //微信信息
  186. phone: '', //手机号
  187. code: '', //验证码
  188. loginStatus: true, //登陆状态
  189. banner: '', //banner图
  190. userRoot: false, //是否有查看报名须知 和 课程介绍的权限
  191. signInfo: '', //报名的数据信息
  192. countDown: 0 //验证码倒计时
  193. };
  194. },
  195. watch: {
  196. isAuthLogin(a) {
  197. if (!a) {
  198. let that = this;
  199. wx.login({
  200. success({ code }) {
  201. that.wechatInfo.code = code;
  202. }
  203. });
  204. }
  205. },
  206. isPhoneLogin(a) {
  207. if (!a) {
  208. this.phone = '';
  209. this.code = '';
  210. }
  211. }
  212. },
  213. filters: {
  214. /**
  215. * 处理富文本里的图片宽度自适应
  216. * 1.去掉img标签里的style、width、height属性
  217. * 2.img标签添加style属性:max-width:100%;height:auto
  218. * 3.修改所有style里的width属性为max-width:100%
  219. * 4.去掉<br/>标签
  220. * @param html
  221. * @returns {void|string|*}
  222. */
  223. formatRichText(html) {
  224. //控制小程序中图片大小
  225. if (html) {
  226. let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
  227. match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
  228. match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  229. match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  230. return match;
  231. });
  232. newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
  233. match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;');
  234. return match;
  235. });
  236. newContent = newContent.replace(/<br[^>]*\/>/gi, '');
  237. newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
  238. return newContent;
  239. }
  240. }
  241. },
  242. onLoad(options) {
  243. if (options.isPhone) {
  244. this.isPhoneLogin = true;
  245. }
  246. },
  247. onShow() {
  248. let that = this;
  249. that.getSetting();
  250. if (!uni.getStorageSync('token')) {
  251. that.isAuthLogin = true;
  252. uni.hideTabBar();
  253. } else {
  254. that.getUserInfo();
  255. }
  256. that.getBanner();
  257. that.tabType = 1;
  258. },
  259. onPullDownRefresh() {
  260. if (uni.getStorageSync('token')) {
  261. this.getUserInfo();
  262. } else {
  263. uni.stopPullDownRefresh();
  264. }
  265. },
  266. onShareAppMessage: function(res) {
  267. const { season_type } = this.userInfo
  268. return {
  269. title: `大卫博士创业${activityType(season_type)}`,
  270. path: '/pages/index/index'
  271. };
  272. },
  273. beforeDestroy() {
  274. clearInterval(this.startTimer, this.offTimer);
  275. },
  276. methods: {
  277. skipData() {
  278. uni.navigateTo({
  279. url: '../statistics/statistics'
  280. });
  281. },
  282. //判断用户是否打开定位权限
  283. getSetting() {
  284. let that = this;
  285. uni.getSetting({
  286. success: res => {
  287. // 从未触发过授权的情况
  288. if (typeof res.authSetting['scope.userLocation'] == 'undefined') {
  289. this.getLocation();
  290. return false;
  291. }
  292. //位置授权关闭 引导开启
  293. if (!res.authSetting['scope.userLocation']) {
  294. uni.showModal({
  295. title: '是否授权当前位置',
  296. content: '如需正常使用本程序,请在授权管理中选中“地理位置”,然后点按返回即可正常使用',
  297. showCancel: false,
  298. success: res => {
  299. if (res.confirm) {
  300. that.openSetting();
  301. }
  302. }
  303. });
  304. return false;
  305. }
  306. //位置授权开启,获取当前位置
  307. if (res.authSetting['scope.userLocation']) {
  308. this.getLocation();
  309. }
  310. },
  311. fail: err => {
  312. console.log(err);
  313. }
  314. });
  315. },
  316. /*引导用户开启定位权限*/
  317. openSetting() {
  318. wx.openSetting({
  319. success: res => {
  320. let that = this;
  321. if (res.authSetting['scope.userLocation']) {
  322. this.getLocation();
  323. }
  324. },
  325. fail: err => {
  326. console.log(err);
  327. uni.showModal({
  328. content: '开启位置权限失败,请手动开启',
  329. showCancel: false
  330. });
  331. }
  332. });
  333. },
  334. getLocation() {
  335. let that = this;
  336. uni.getLocation({
  337. // 用户同意授权地理位置
  338. success: ({ latitude, longitude }) => {
  339. that.wechatInfo.latitude = latitude;
  340. that.wechatInfo.longitude = longitude;
  341. },
  342. fail: function(err) {
  343. // 授权地理位置调用失败
  344. // if (err.errMsg == 'getLocation:fail system permission denied') {
  345. // uni.showModal({
  346. // content: '获取位置失败,请检查手机GPS或者微信使用手机定位权限是否开启',
  347. // showCancel: false
  348. // });
  349. // return false;
  350. // }
  351. if (err.errMsg == 'getLocation:fail auth deny') {
  352. uni.showModal({
  353. title: '是否授权当前位置',
  354. content: '取消位置授权,将影响您使用小程序,请重新开启授权',
  355. showCancel: false,
  356. success: res => {
  357. if (res.confirm) {
  358. that.openSetting();
  359. }
  360. }
  361. });
  362. }
  363. }
  364. });
  365. },
  366. getSignInfo() {
  367. signInfo().then(res => {
  368. if (res.code == 200) {
  369. this.signInfo = res.data;
  370. } else {
  371. uni.showModal({
  372. content: res.msg || '获取失败',
  373. showCancel: false
  374. });
  375. }
  376. });
  377. },
  378. //跳转到报名管理
  379. skipList() {
  380. uni.navigateTo({
  381. url: '../sign_up_list/sign_up_list'
  382. });
  383. },
  384. // 代理签到
  385. signIn() {
  386. uni.navigateTo({
  387. url: '../sign_in/sign_in'
  388. });
  389. },
  390. //获取活动banner
  391. getBanner() {
  392. getBanner().then(res => {
  393. this.banner = res.data;
  394. });
  395. },
  396. /*tab 切换
  397. * 1 报名须知 2 课程介绍 3 报名凭证
  398. */
  399. tabSkip(type) {
  400. this.tabType = type;
  401. if (type == 2) {
  402. uni.navigateTo({
  403. url: '../course_intr/course_intr?banner=' + this.banner.banner_2
  404. });
  405. return false;
  406. }
  407. if (type == 3) {
  408. if (!this.userInfo.sign_type) {
  409. this.tabType = 1;
  410. uni.showModal({
  411. content: '您还未报过名',
  412. showCancel: false
  413. });
  414. return false;
  415. }
  416. uni.navigateTo({
  417. url: '../sign_up_voucher/sign_up_voucher'
  418. });
  419. }
  420. },
  421. /* 获取验证码
  422. *@params phone 手机号
  423. */
  424. getCode() {
  425. let that = this;
  426. if (that.countDown) {
  427. uni.showModal({
  428. content: '验证码已发送,请稍后重试',
  429. showCancel: false
  430. });
  431. return false;
  432. }
  433. if (!that.phone) {
  434. uni.showModal({
  435. content: '请输入手机号',
  436. showCancel: false
  437. });
  438. return false;
  439. }
  440. sendCode({
  441. phone: that.phone
  442. }).then(res => {
  443. if (res.code != 200) {
  444. uni.showModal({
  445. content: res.message || '获取验证码失败',
  446. showCancel: false
  447. });
  448. return false;
  449. }
  450. if (res.code == 200) {
  451. uni.showModal({
  452. content: '验证码发送成功',
  453. showCancel: false
  454. });
  455. this.countDown = 60;
  456. this.timer = setInterval(() => {
  457. this.countDown--;
  458. if (!this.countDown) {
  459. this.countDown = 0;
  460. clearInterval(this.timer);
  461. }
  462. }, 1000);
  463. }
  464. });
  465. },
  466. /*微信登录获取 token
  467. * @params openid用户openid 传空
  468. * @params avatar 用户头像
  469. * @params nickname 用户昵称
  470. * @params code 微信登录code
  471. * @params longitude 用户位置经度
  472. * @params latitude 用户位置维度
  473. */
  474. userLogin({ detail }) {
  475. let that = this;
  476. if (detail.errMsg === 'getUserInfo:ok') {
  477. that.wechatInfo.avatarUrl = detail.userInfo.avatarUrl;
  478. that.wechatInfo.nickName = detail.userInfo.nickName;
  479. uni.login({
  480. success: ({ code }) => {
  481. that.wechatInfo.code = code;
  482. // if (!that.wechatInfo.longitude && !that.wechatInfo.latitude) {
  483. // uni.showModal({
  484. // content: '暂无位置信息,请检查手机GPS或者微信使用手机定位权限是否开启',
  485. // showCancel: false
  486. // });
  487. // return false;
  488. // }
  489. let { avatarUrl, nickName, latitude, longitude } = that.wechatInfo;
  490. wecatLogin({
  491. openid: '',
  492. avatar: avatarUrl,
  493. nickname: nickName,
  494. code: code,
  495. longitude: longitude,
  496. latitude: latitude
  497. })
  498. .then(res => {
  499. if (res.code === 300) {
  500. that.isAuthLogin = false;
  501. that.isPhoneLogin = true;
  502. } else if (res.code === 200) {
  503. uni.showTabBar();
  504. uni.setStorageSync('token', res.data.token);
  505. that.getUserInfo();
  506. } else {
  507. uni.showModal({
  508. content: res.message,
  509. showCancel: false
  510. });
  511. }
  512. })
  513. .catch(e => {})
  514. .finally(() => {
  515. that.isAuthLogin = false;
  516. });
  517. }
  518. });
  519. } else {
  520. uni.showModal({
  521. content: '不授权将无法获取到您的信息,请手动开启授权',
  522. showCancel: false,
  523. success: res => {
  524. if (res.confirm) {
  525. wx.openSetting({
  526. success: res => {
  527. let that = this;
  528. if (res.authSetting['scope.userInfo']) {
  529. uni.showModal({
  530. content: '用户权限已开启',
  531. showCancel: false
  532. });
  533. } else {
  534. uni.showModal({
  535. content: '您拒绝了用户信息权限',
  536. showCancel: false
  537. });
  538. }
  539. },
  540. fail: err => {
  541. uni.showModal({
  542. content: '开启用户信息权限失败',
  543. showCancel: false
  544. });
  545. }
  546. });
  547. }
  548. }
  549. });
  550. }
  551. },
  552. /*手机验证码登陆
  553. * @params phone 用户手机号
  554. * @params phone_code 用户验证码
  555. * @params avatar 用户头像
  556. * @params nickname 用户昵称
  557. * @params longitude 用户位置经度
  558. * @params latitude 用户位置维度
  559. * @params code 微信登录code
  560. */
  561. phoneLogin() {
  562. let that = this;
  563. if (!that.phone) {
  564. uni.showModal({
  565. content: '手机号不存在',
  566. showCancel: false
  567. });
  568. return false;
  569. }
  570. if (!that.code) {
  571. uni.showModal({
  572. content: '验证码不存在',
  573. showCancel: false
  574. });
  575. return false;
  576. }
  577. if (!that.loginStatus) return false;
  578. that.loginStatus = false;
  579. uni.login({
  580. success: ({ code }) => {
  581. phoneLogin({
  582. phone: that.phone,
  583. phone_code: that.code,
  584. avatar: that.wechatInfo.avatarUrl,
  585. nickname: that.wechatInfo.nickName,
  586. longitude: that.wechatInfo.longitude,
  587. latitude: that.wechatInfo.latitude,
  588. code
  589. })
  590. .then(res => {
  591. if (res.code === 200) {
  592. this.isPhoneLogin = false;
  593. uni.setStorageSync('token', res.data.token);
  594. that.getUserInfo();
  595. } else {
  596. uni.showModal({
  597. content: res.message || '请求失败',
  598. showCancel: false
  599. });
  600. }
  601. })
  602. .catch(e => {})
  603. .finally(() => {
  604. that.loginStatus = true;
  605. });
  606. }
  607. });
  608. },
  609. // 倒计时
  610. coutdown(date) {
  611. const add0 = num => (num < 10 ? '0' + num : num);
  612. const now = Math.floor(Date.now() / 1000);
  613. let sec = Math.floor(Number(date) - now);
  614. if (sec > 0) {
  615. const day = Math.floor(sec / 86400);
  616. const hour = Math.floor((sec % 86400) / 3600);
  617. const minite = Math.floor((sec - 86400 * day - hour * 3600) / 60);
  618. const second = Math.floor(sec - 86400 * day - hour * 3600 - minite * 60);
  619. return `${add0(day)}天${add0(hour)}时${add0(minite)}分${add0(second)}秒`;
  620. } else {
  621. this.offTimer = this.startTimer = null;
  622. return false;
  623. }
  624. },
  625. startLine() {
  626. let that = this;
  627. let now = Math.floor(Date.now() / 1000);
  628. let offStart = Math.floor(Number(that.userInfo.sign_start) - now);
  629. if (offStart > 0) {
  630. that.offTimer = setInterval(() => {
  631. that.offStart = that.coutdown(that.userInfo.sign_start);
  632. }, 1000);
  633. if (!that.offStart) {
  634. this.offline();
  635. }
  636. }
  637. },
  638. //报名倒计时
  639. offline() {
  640. let that = this;
  641. let now = Math.floor(Date.now() / 1000);
  642. // let offStart = Math.floor(Number(that.userInfo.sign_start) - now);
  643. let offEnd = Math.floor(Number(that.userInfo.sign_end) - now);
  644. // if (offStart > 0) {
  645. // that.offTimer = setInterval(() => {
  646. // that.offStart = that.coutdown(that.userInfo.sign_start);
  647. // }, 1000);
  648. // }
  649. if (offEnd > 0) {
  650. that.offTimer = setInterval(() => {
  651. that.offEnd = that.coutdown(that.userInfo.sign_end);
  652. }, 1000);
  653. if (!that.offEnd) {
  654. that.timeLine();
  655. }
  656. }
  657. },
  658. //培训开始时间倒计时
  659. timeLine() {
  660. let that = this;
  661. let now = Math.floor(Date.now() / 1000);
  662. let timeStart = Math.floor(Number(that.userInfo.time_start) - now);
  663. if (timeStart > 0) {
  664. that.startTimer = setInterval(() => {
  665. that.timeStart = that.coutdown(that.userInfo.time_start);
  666. }, 1000);
  667. }
  668. },
  669. // 获取用户信息
  670. getUserInfo() {
  671. var that = this;
  672. that.getSetting();
  673. // if (!that.wechatInfo.latitude && that.wechatInfo.longitude) {
  674. // that.getSetting();
  675. // return false;
  676. // }
  677. // uni.getLocation({
  678. // })
  679. let { latitude, longitude } = that.wechatInfo;
  680. getUserInfo({
  681. latitude,
  682. longitude
  683. })
  684. .then(res => {
  685. if (res.code === 200) {
  686. uni.showTabBar();
  687. this.userInfo = res.data;
  688. // this.userInfo.type = 1
  689. uni.setStorageSync('userInfo', res.data);
  690. let { time_start, time_end, sign_start, sign_end, is_limit, count, limit_num, level, season_type, type } = this.userInfo;
  691. if (type == 1) {
  692. this.getSignInfo();
  693. }
  694. if (sign_start * 1000 > Date.now()) {
  695. //报名未开始
  696. this.startLine();
  697. }
  698. if (sign_end * 1000 > Date.now()) {
  699. //报名未结束
  700. this.offline();
  701. }
  702. if (sign_end * 1000 < Date.now() && time_start * 1000 > Date.now()) {
  703. //报名已截止,活动未开始 距离培训开始倒计时
  704. this.timeLine();
  705. }
  706. if (sign_start * 1000 < Date.now() && sign_end * 1000 > Date.now() && is_limit && Number(count) === Number(limit_num)) {
  707. //报名进行中 但是报名人数已满
  708. this.limitState = false;
  709. } else {
  710. this.limitState = true;
  711. }
  712. if (time_start * 1000 > Date.now() || time_end * 1000 < Date.now()) {
  713. //活动还未开始 或者活动已结束
  714. this.offSate = false;
  715. } else {
  716. this.offSate = true;
  717. }
  718. if (season_type == '0' && (level == '销售经理' || level == '代理公司')) {
  719. //实战营 报名须知 课程介绍只能有权限报名的人看
  720. this.userRoot = true;
  721. }
  722. if (season_type == '1' && level == '代理公司') {
  723. this.userRoot = true;
  724. }
  725. } else {
  726. uni.showModal({
  727. content: res.message,
  728. showCancel: false
  729. });
  730. }
  731. })
  732. .catch(e => {})
  733. .finally(() => {
  734. uni.stopPullDownRefresh();
  735. });
  736. },
  737. //活动报名
  738. signUp(type) {
  739. let that = this;
  740. if (!uni.getStorageSync('userInfo')) {
  741. uni.showModal({
  742. content: '请先登录',
  743. showCancel: false,
  744. success: () => {
  745. this.isPhoneLogin = true;
  746. }
  747. });
  748. return false;
  749. }
  750. if (type == 1) {
  751. //如果是管理员
  752. uni.navigateTo({
  753. url: '../sign_manage/sign_manage?from=' + 'index' + '&banner=' + this.banner.banner_1
  754. });
  755. return false;
  756. }
  757. if (that.userInfo.sign_up) {
  758. //已报名
  759. uni.navigateTo({
  760. url: '../sign_up_info/sign_up_info'
  761. });
  762. return false;
  763. }
  764. //未报名
  765. if (that.offStart) {
  766. uni.showModal({
  767. content: '报名还未开始',
  768. showCancel: false
  769. });
  770. return false;
  771. }
  772. if (!that.offEnd && !that.offStart) {
  773. uni.showModal({
  774. content: '本届报名已截止,欢迎下次报名',
  775. showCancel: false
  776. });
  777. return false;
  778. }
  779. if (that.userInfo.is_limit && Number(that.userInfo.count) == Number(that.userInfo.limit_num)) {
  780. uni.showModal({
  781. content: '报名人数已满',
  782. showCancel: false
  783. });
  784. return false;
  785. }
  786. if (that.userInfo.enroll_t) {
  787. //报名之后退款 无法重复报名
  788. uni.showModal({
  789. title: '温馨提示',
  790. content: '已发生过一次退款,本届你不能再报名\n欢迎下次报名参加!',
  791. showCancel: false
  792. });
  793. return false;
  794. }
  795. if (that.userInfo.season_type == 1 && that.userInfo.level != '代理公司') {
  796. uni.showModal({
  797. content: '密训营只能代理公司参加',
  798. showCancel: false
  799. });
  800. return false;
  801. }
  802. // if (that.userInfo.season_type == 0 && (that.userInfo.level != '销售经理' || that.userInfo.level != '代理公司')) {
  803. // uni.showModal({
  804. // content: '实战营只能销售经理或代理公司参加',
  805. // showCancel: false
  806. // });
  807. // return false;
  808. // }
  809. uni.navigateTo({
  810. url: '../sign_up/sign_up?banner=' + this.banner.banner_1
  811. });
  812. },
  813. getTime(date) {
  814. var time = new Date(Number(date) * 1000);
  815. var year = time.getFullYear();
  816. var month = time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1;
  817. var day = time.getDate() < 10 ? '0' + time.getDate() : time.getDate();
  818. var today = year + '.' + month + '.' + day;
  819. return today;
  820. }
  821. }
  822. };
  823. </script>
  824. <style lang="scss" scoped>
  825. .loginText {
  826. padding: 20rpx;
  827. font-size: 32rpx;
  828. line-height: 50rpx;
  829. }
  830. .loginBtn {
  831. position: fixed;
  832. top: 0;
  833. left: 0;
  834. bottom: 0;
  835. right: 0;
  836. z-index: 99;
  837. opacity: 0;
  838. }
  839. .allCount {
  840. width: 690rpx;
  841. height: 320rpx;
  842. margin: 0 auto;
  843. background-color: #fff;
  844. padding: 25rpx 30rpx;
  845. box-sizing: border-box;
  846. border-radius: 8rpx;
  847. .title {
  848. margin-bottom: 50rpx;
  849. > text {
  850. font-size: 32rpx;
  851. color: #333;
  852. }
  853. > view {
  854. text {
  855. font-size: 28rpx;
  856. color: #666;
  857. }
  858. }
  859. }
  860. .count {
  861. width: 98%;
  862. margin: 0 auto;
  863. }
  864. image {
  865. height: 30rpx;
  866. width: 30rpx;
  867. vertical-align: middle;
  868. }
  869. .flexCC {
  870. > text {
  871. font-size: 28rpx;
  872. margin-top: 50rpx;
  873. }
  874. view {
  875. s text {
  876. font-size: 36rpx;
  877. }
  878. }
  879. }
  880. }
  881. .statistics {
  882. height: 352rpx;
  883. margin-top: 20rpx;
  884. .classify {
  885. image {
  886. height: 193rpx;
  887. width: 193rpx;
  888. }
  889. text {
  890. font-size: 26rpx;
  891. color: #333;
  892. margin-top: 15rpx;
  893. }
  894. }
  895. .title {
  896. margin-bottom: 20rpx;
  897. }
  898. }
  899. .submit_container {
  900. position: fixed;
  901. left: 0;
  902. right: 0;
  903. bottom: 0;
  904. width: 100%;
  905. font-size: 36rpx;
  906. background: #fff;
  907. z-index: 999;
  908. height: 118rpx;
  909. display: flex;
  910. justify-content: space-between;
  911. align-items: center;
  912. border-top: 1rpx solid #f9f9f9;
  913. padding: 0 30rpx;
  914. box-sizing: border-box;
  915. .share {
  916. image {
  917. height: 46rpx;
  918. width: 46rpx;
  919. }
  920. view {
  921. font-size: 28rpx;
  922. color: #333333;
  923. margin-top: 5rpx;
  924. }
  925. }
  926. .sign_up {
  927. width: 690rpx;
  928. height: 90rpx;
  929. background-color: #ea4a41;
  930. border-radius: 45rpx;
  931. color: #ffffff;
  932. letter-spacing: 5rpx;
  933. image {
  934. width: 42rpx;
  935. height: 42rpx;
  936. margin-right: 17rpx;
  937. }
  938. }
  939. }
  940. .home {
  941. width: 100vw;
  942. position: relative;
  943. padding-bottom: 130rpx;
  944. }
  945. .desc_btn {
  946. width: 100%;
  947. height: 80rpx;
  948. background: #ea4a41;
  949. border-radius: 0 0 8rpx 8rpx;
  950. color: #fff;
  951. font-size: 36rpx;
  952. margin-bottom: 15rpx;
  953. }
  954. .offline_btn,
  955. .look {
  956. background: $offline-color;
  957. // border: 4rpx solid $offline-color;
  958. }
  959. .no_btn {
  960. background: #cdcbcc;
  961. // border: 4rpx solid #cdcbcc;
  962. }
  963. .tab {
  964. width: 100%;
  965. height: 90rpx;
  966. display: flex;
  967. justify-content: space-around;
  968. align-items: center;
  969. background: #fff;
  970. view {
  971. height: 85rpx;
  972. line-height: 85rpx;
  973. font-size: 32rpx;
  974. letter-spacing: 5rpx;
  975. font-weight: 500;
  976. color: #666;
  977. &::after {
  978. content: '';
  979. display: block;
  980. width: 130rpx;
  981. height: 4rpx;
  982. border-radius: 2rpx;
  983. margin-left: 19rpx;
  984. }
  985. image {
  986. height: 40rpx;
  987. width: 40rpx;
  988. vertical-align: middle;
  989. margin-right: 15rpx;
  990. }
  991. text {
  992. font-size: 24rpx;
  993. color: #333;
  994. }
  995. }
  996. .active {
  997. color: #ea4a41;
  998. &::after {
  999. background-color: #ea4a41;
  1000. }
  1001. }
  1002. }
  1003. .richText {
  1004. width: 690rpx;
  1005. margin: 0 auto;
  1006. padding: 20rpx;
  1007. background-color: #fff;
  1008. font-size: 28rpx;
  1009. }
  1010. uni-rich-text img {
  1011. max-width: 100% !important;
  1012. }
  1013. .phone_login {
  1014. position: fixed;
  1015. top: 0;
  1016. bottom: 0;
  1017. left: 0;
  1018. right: 0;
  1019. z-index: 999;
  1020. display: flex;
  1021. align-items: center;
  1022. justify-content: center;
  1023. background-color: rgba(0, 0, 0, 0.3);
  1024. .phone_container {
  1025. width: 570rpx;
  1026. background-color: #ffffff;
  1027. border-radius: 10rpx;
  1028. overflow: hidden;
  1029. position: relative;
  1030. .close {
  1031. &::before {
  1032. position: absolute;
  1033. top: 26rpx;
  1034. right: 26rpx;
  1035. content: '\2716';
  1036. display: block;
  1037. width: 30rpx;
  1038. height: 30rpx;
  1039. color: #ffffff;
  1040. z-index: 9999;
  1041. }
  1042. }
  1043. .top {
  1044. width: 100%;
  1045. height: 220rpx;
  1046. background-color: #fa6342;
  1047. color: #ffffff;
  1048. font-size: 40rpx;
  1049. padding-top: 50rpx;
  1050. font-weight: blod;
  1051. box-sizing: border-box;
  1052. display: flex;
  1053. justify-content: flex-start;
  1054. flex-direction: column;
  1055. align-items: center;
  1056. position: relative;
  1057. .userImg {
  1058. position: absolute;
  1059. width: 138rpx;
  1060. height: 138rpx;
  1061. border-radius: 50%;
  1062. bottom: -69rpx;
  1063. overflow: hidden;
  1064. .getImgBtn {
  1065. width: 138rpx;
  1066. height: 138rpx;
  1067. }
  1068. }
  1069. }
  1070. .bottom {
  1071. padding: 100rpx 60rpx 30rpx;
  1072. background-color: #ffffff;
  1073. .input {
  1074. width: 100%;
  1075. height: 70rpx;
  1076. padding: 0 17rpx;
  1077. box-sizing: border-box;
  1078. color: #000000;
  1079. font-size: 30rpx;
  1080. background-color: #eeeeee;
  1081. border-radius: 2rpx;
  1082. }
  1083. .bottom_eqcode {
  1084. display: flex;
  1085. justify-content: space-between;
  1086. align-items: center;
  1087. margin-top: 60rpx;
  1088. .eqcode_input {
  1089. width: 240rpx;
  1090. }
  1091. .eqcode {
  1092. width: calc(100% - 240rpx);
  1093. color: #fa6342;
  1094. font-size: 32rpx;
  1095. text-align: right;
  1096. }
  1097. }
  1098. }
  1099. .submit_btn {
  1100. width: 100%;
  1101. height: 86rpx;
  1102. line-height: 86rpx;
  1103. text-align: center;
  1104. background-color: rgba(250, 99, 66, 0.2);
  1105. color: #fa6342;
  1106. font-size: 32rpx;
  1107. }
  1108. }
  1109. }
  1110. .no_location,
  1111. .auth_login {
  1112. position: fixed;
  1113. top: 0;
  1114. bottom: 0;
  1115. left: 0;
  1116. right: 0;
  1117. z-index: 999;
  1118. width: 100vw;
  1119. height: 100vh;
  1120. background-color: rgba(0, 0, 0, 0.8);
  1121. }
  1122. .no_location {
  1123. .no_con {
  1124. width: 80%;
  1125. background: #fff;
  1126. margin: 0 auto;
  1127. }
  1128. }
  1129. .auth_login {
  1130. .auth_btn {
  1131. width: 80%;
  1132. height: 88rpx;
  1133. background: #ea4a41;
  1134. color: #fff;
  1135. }
  1136. }
  1137. .phone_login {
  1138. position: fixed;
  1139. top: 0;
  1140. bottom: 0;
  1141. left: 0;
  1142. right: 0;
  1143. z-index: 999;
  1144. display: flex;
  1145. align-items: center;
  1146. justify-content: center;
  1147. background-color: rgba(0, 0, 0, 0.3);
  1148. .phone_container {
  1149. width: 570rpx;
  1150. background-color: #ffffff;
  1151. border-radius: 10rpx;
  1152. overflow: hidden;
  1153. position: relative;
  1154. .close {
  1155. &::before {
  1156. position: absolute;
  1157. top: 26rpx;
  1158. right: 26rpx;
  1159. content: '\2716';
  1160. display: block;
  1161. width: 30rpx;
  1162. height: 30rpx;
  1163. color: #ffffff;
  1164. z-index: 9999;
  1165. }
  1166. }
  1167. .top {
  1168. width: 100%;
  1169. height: 220rpx;
  1170. background-color: #fa6342;
  1171. color: #ffffff;
  1172. font-size: 40rpx;
  1173. padding-top: 50rpx;
  1174. font-weight: blod;
  1175. box-sizing: border-box;
  1176. display: flex;
  1177. justify-content: flex-start;
  1178. flex-direction: column;
  1179. align-items: center;
  1180. position: relative;
  1181. .userImg {
  1182. position: absolute;
  1183. width: 138rpx;
  1184. height: 138rpx;
  1185. border-radius: 50%;
  1186. bottom: -69rpx;
  1187. overflow: hidden;
  1188. .getImgBtn {
  1189. width: 138rpx;
  1190. height: 138rpx;
  1191. }
  1192. }
  1193. }
  1194. .bottom {
  1195. padding: 100rpx 60rpx 30rpx;
  1196. background-color: #ffffff;
  1197. .input {
  1198. width: 100%;
  1199. height: 70rpx;
  1200. padding: 0 17rpx;
  1201. box-sizing: border-box;
  1202. color: #000000;
  1203. font-size: 30rpx;
  1204. background-color: #eeeeee;
  1205. border-radius: 2rpx;
  1206. }
  1207. .bottom_eqcode {
  1208. display: flex;
  1209. justify-content: space-between;
  1210. align-items: center;
  1211. margin-top: 60rpx;
  1212. .eqcode_input {
  1213. width: 240rpx;
  1214. }
  1215. .eqcode {
  1216. width: calc(100% - 240rpx);
  1217. color: #fa6342;
  1218. font-size: 32rpx;
  1219. text-align: right;
  1220. }
  1221. }
  1222. }
  1223. .submit_btn {
  1224. width: 100%;
  1225. height: 86rpx;
  1226. line-height: 86rpx;
  1227. text-align: center;
  1228. background-color: rgba(250, 99, 66, 0.2);
  1229. color: #fa6342;
  1230. font-size: 32rpx;
  1231. }
  1232. }
  1233. }
  1234. .banner_main {
  1235. width: 730rpx;
  1236. height: 369rpx;
  1237. margin: 0 auto;
  1238. image {
  1239. height: 100%;
  1240. width: 100%;
  1241. border-radius: 15rpx;
  1242. }
  1243. }
  1244. .index_container {
  1245. width: 690rpx;
  1246. margin: 0 auto;
  1247. padding-top: 20rpx;
  1248. .sign_up_container {
  1249. width: 100%;
  1250. position: relative;
  1251. box-sizing: border-box;
  1252. padding: 30rpx;
  1253. display: flex;
  1254. justify-content: space-between;
  1255. flex-direction: column;
  1256. background-color: #ffffff;
  1257. // border-radius: 8rpx;
  1258. border-radius: 8rpx 8rpx 0 0;
  1259. margin-top: 16rpx;
  1260. overflow: hidden;
  1261. .top {
  1262. color: #333333;
  1263. font-size: 32rpx;
  1264. font-weight: bold;
  1265. display: flex;
  1266. align-items: center;
  1267. justify-content: flex-start;
  1268. margin-bottom: 40rpx;
  1269. padding-top: 25rpx;
  1270. &::before {
  1271. content: '';
  1272. display: block;
  1273. width: 44rpx;
  1274. height: 44rpx;
  1275. background-image: url(../../static/imgs/offline.png);
  1276. background-size: 100% 100%;
  1277. margin-right: 10rpx;
  1278. }
  1279. }
  1280. .line {
  1281. &::before {
  1282. background-image: url(../../static/imgs/online.png);
  1283. }
  1284. }
  1285. .bottom {
  1286. display: flex;
  1287. justify-content: space-between;
  1288. align-items: flex-start;
  1289. .desc_main {
  1290. width: calc(100% - 168rpx);
  1291. color: #333333;
  1292. font-size: 26rpx;
  1293. .bot_parent,
  1294. .online {
  1295. display: flex;
  1296. justify-content: flex-start;
  1297. align-items: center;
  1298. margin-bottom: 16rpx;
  1299. &:nth-last-of-type(1) {
  1300. margin-bottom: 0;
  1301. }
  1302. &::before {
  1303. content: '';
  1304. display: block;
  1305. width: 10rpx;
  1306. height: 10rpx;
  1307. border-radius: 50%;
  1308. background-color: #f76454;
  1309. margin-right: 14rpx;
  1310. }
  1311. }
  1312. .online {
  1313. &::before {
  1314. background-color: #fcbe18;
  1315. }
  1316. }
  1317. }
  1318. }
  1319. .surplus,
  1320. .line_surplus {
  1321. display: flex;
  1322. align-items: center;
  1323. margin-top: 16rpx;
  1324. font-size: 26rpx;
  1325. color: #333333;
  1326. &::before {
  1327. content: '';
  1328. display: block;
  1329. width: 10rpx;
  1330. height: 10rpx;
  1331. border-radius: 50%;
  1332. background-color: #f76454;
  1333. margin-right: 14rpx;
  1334. }
  1335. }
  1336. .signedNum {
  1337. justify-content: space-between;
  1338. &_item {
  1339. flex:1;
  1340. overflow: hidden;
  1341. }
  1342. }
  1343. .line_surplus {
  1344. &::before {
  1345. background-color: #fcbe18;
  1346. }
  1347. }
  1348. .tip_container {
  1349. width: 138rpx;
  1350. height: 55rpx;
  1351. position: absolute;
  1352. top: 0;
  1353. right: 0;
  1354. border-bottom-left-radius: 55rpx;
  1355. color: #ffffff;
  1356. font-size: 26rpx;
  1357. line-height: 55rpx;
  1358. text-align: right;
  1359. padding: 0 14rpx;
  1360. box-sizing: border-box;
  1361. }
  1362. .on_line {
  1363. background-color: $online-color;
  1364. }
  1365. .off_line {
  1366. background-color: $offline-color;
  1367. }
  1368. .finish {
  1369. background-color: #cdcbcc;
  1370. }
  1371. }
  1372. }
  1373. </style>