index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <view class="ezy-my-page">
  3. <view class="my-head-box">
  4. <icon class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.icon + ')'}"></icon>
  5. <view class="head-content-box">
  6. <text>{{myInfoData.nickName}}</text>
  7. <view class="ezy-jf-box" v-if="loginFlag">
  8. <icon class="jf-icon"></icon>
  9. <text class="jf-text">{{myInfoData.credit}}</text>
  10. </view>
  11. </view>
  12. </view>
  13. <swiper class="my-hyqy-swiper" circular :indicator-dots="hyqyData.indicatorDots" :autoplay="hyqyData.autoplay"
  14. :interval="hyqyData.interval" :duration="hyqyData.duration" indicator-color="#5195d3"
  15. indicator-active-color="#83d9ff" v-if="bannerArr">
  16. <!-- 1.数学 2.英语-->
  17. <swiper-item v-for="(item, index) in bannerArr" :key="index" class="hyqy-box" @click="hyqyBtn(item)">
  18. <img :src="item.addCover" class="hyqy-box-img" />
  19. </swiper-item>
  20. </swiper>
  21. <!--
  22. <view class="list-row" @click="telClick">
  23. <icon class="list-icon tel-icon"></icon>
  24. <text>手机号码</text>
  25. </view>
  26. <view class="list-row" @click="aboutClick">
  27. <icon class="list-icon about-icon"></icon>
  28. <text>关于我们</text>
  29. </view>
  30. <view v-if="loginFlag" class="list-row" @click="xxscClick">
  31. <icon class="list-icon sxtk-icon"></icon>
  32. <text>学习时长</text>
  33. </view>
  34. <view v-if="loginFlag" class="list-row" @click="yinsizhengce">
  35. <icon class="list-icon yszc-icon"></icon>
  36. <text>隐私政策</text>
  37. </view>
  38. -->
  39. <view class="my-list-box">
  40. <view class="list-item" @click="xxjlClick">
  41. <icon class="list-icon xxjl-icon"></icon>
  42. <text>学习记录</text>
  43. </view>
  44. <view class="list-item" @click="checkWrong">
  45. <icon class="list-icon error-icon"></icon>
  46. <text>我的错题</text>
  47. </view>
  48. <view class="list-item" @click="sxtkClick">
  49. <icon class="list-icon sxtk-icon"></icon>
  50. <text>数学题库</text>
  51. </view>
  52. <view v-if="appleCode=='true'&&currentPlatform=='ios'" class="list-item" @click="duihuamaDuihuan">
  53. <icon class="list-icon duihuanma-icon"></icon>
  54. <text>兑换码</text>
  55. </view>
  56. <view v-if="currentPlatform=='android'" class="list-item" @click="duihuamaDuihuan">
  57. <icon class="list-icon duihuanma-icon"></icon>
  58. <text>兑换码</text>
  59. </view>
  60. </view>
  61. <view class="my-list-box">
  62. <view class="list-item" @click="cpscClick">
  63. <icon class="list-icon cpsc-icon"></icon>
  64. <text>产品商城</text>
  65. </view>
  66. <view class="list-item" @click="orderClick">
  67. <icon class="list-icon order-icon"></icon>
  68. <text>我的订单</text>
  69. </view>
  70. <view class="list-item" @click="kefudianhua">
  71. <icon class="list-icon kfdh-icon"></icon>
  72. <text>客服电话</text>
  73. </view>
  74. <view class="list-item" @click="yingyongshezhi">
  75. <icon class="list-icon yysz-icon"></icon>
  76. <text>应用设置</text>
  77. </view>
  78. </view>
  79. <view class="my-list-box">
  80. <view class="list-item" @click="yonghuzhuxiao">
  81. <icon class="list-icon zhuxiao-icon"></icon>
  82. <text>用户注销</text>
  83. </view>
  84. <view class="list-item" @click="exitLogin">
  85. <icon class="list-icon login-out-icon"></icon>
  86. <text>退出登录</text>
  87. </view>
  88. </view>
  89. <CustomTabBar :levelId="levelId" :currentTabNumber="3" :typeId="typeId" :subjectId="subjectId"
  90. :tipFlag="tipFlag">
  91. </CustomTabBar>
  92. <tip-small-dialog ref="exitDialogRef" @confirm-btn="exitBtn" :content="tipContent"></tip-small-dialog>
  93. <tip-big-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :imgShow="true"></tip-big-dialog>
  94. <tip-small-dialog ref="zhuxiaoDialogRef" @confirm-btn="zhuxiaoBtn" :content="zhuxiaoContent"></tip-small-dialog>
  95. <duihuanmaDialog ref="duihuanmaDialogRef" @confirm-btn="duihuanmaBtn" title="兑换"></duihuanmaDialog>
  96. <tel-dialog @telClose="telClose" @bindBtn="bindBtn" v-if="telDialogFlag"></tel-dialog>
  97. <agree-content-dialog ref="agreeContentDialogRef" :agreeType="agreeType"></agree-content-dialog>
  98. <tip-small-dialog ref="kefuDialogRef" :title="kefuTitle" @confirm-btn="kefuBtn" :content="kefuContent"
  99. class="kefu-dialog"></tip-small-dialog>
  100. </view>
  101. </template>
  102. <script setup>
  103. import agreeContentDialog from '@/pages/login/agreeContentDialog.vue';
  104. import {
  105. toast,
  106. getUserIdentity
  107. } from "@/utils/common";
  108. import cacheManager from '@/utils/cacheManager.js';
  109. import {
  110. logout
  111. } from '@/api/login.js'
  112. import {
  113. myInfo,
  114. zhuxiao,
  115. duihuanmaCode,
  116. myCardList,
  117. commonCardList
  118. } from '@/api/my.js'
  119. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  120. import {
  121. getCurrentInstance
  122. } from 'vue';
  123. import {
  124. onLoad
  125. } from '@dcloudio/uni-app';
  126. import {
  127. reactive,
  128. ref
  129. } from "vue";
  130. import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue';
  131. import duihuanmaDialog from '@/components/dialog/duihuanmaDialog.vue';
  132. import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
  133. import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
  134. import telDialog from './telDialog.vue'
  135. import {
  136. MESSAGE_VISITER_TO_LOGIN
  137. } from "@/utils/constant.js"
  138. import {
  139. onShow
  140. } from '@dcloudio/uni-app';
  141. onShow(() => {
  142. if (!cacheManager.get('auth')) {
  143. youkeFun();
  144. } else {
  145. // 非游客
  146. noYoukeFun();
  147. }
  148. })
  149. const agreeType = ref(null);
  150. const agreeContentDialogRef = ref(null);
  151. const subjectId = ref(null); //游客使用
  152. const levelId = ref(null); //游客使用
  153. const typeId = ref(null); //游客使用
  154. const tipFlag = ref(null); //游客使用
  155. const tipContent = '你确定要执行这个操作吗?';
  156. const zhuxiaoContent = '你确定要执行这个操作吗?';
  157. const duihuanmaContent = '你确定要执行这个操作吗?';
  158. let hyqyData = reactive({
  159. indicatorDots: true,
  160. autoplay: true,
  161. interval: 10000,
  162. duration: 500
  163. });
  164. let loginFlag = ref(false);
  165. let telDialogFlag = ref(false);
  166. let myInfoData = reactive({
  167. userImg: '',
  168. userName: '',
  169. credit: '',
  170. vipFlag: '',
  171. nickName: '',
  172. icon: '',
  173. });
  174. let routerOpt = ref(false);
  175. let appleCode = ref(null);
  176. let currentPlatform = ref(null);
  177. const exitDialogRef = ref(null);
  178. const youkeDialogRef = ref(null);
  179. const zhuxiaoDialogRef = ref(null);
  180. const duihuanmaDialogRef = ref(null);
  181. const bannerArr = ref(null);
  182. const kefuDialogRef = ref(null);
  183. const kefuTitle = '提示';
  184. const kefuContent = '客服电话:17304117625';
  185. const exitLogin = () => {
  186. exitDialogRef.value.handleShow();
  187. }
  188. // 退出按钮
  189. const exitBtn = () => {
  190. if (loginFlag.value) {
  191. logout().then(res => {
  192. toast('退出登录成功')
  193. cacheManager.clearAll();
  194. uni.reLaunch({
  195. url: '/pages/login/index'
  196. });
  197. }).catch(err => {
  198. toast('退出登录失败,请稍后重试')
  199. })
  200. } else {
  201. uni.reLaunch({
  202. url: '/pages/login/index'
  203. });
  204. }
  205. }
  206. const zhuxiaoBtn = () => {
  207. let req = {
  208. }
  209. zhuxiao().then(res => {
  210. cacheManager.clearAll();
  211. toast('用户注销成功')
  212. uni.redirectTo({
  213. url: '/pages/login/index'
  214. });
  215. }).catch(err => {
  216. toast('失败,请稍后重试')
  217. })
  218. }
  219. function yonghuzhuxiao() {
  220. if (loginFlag.value) {
  221. zhuxiaoDialogRef.value.handleShow();
  222. } else {
  223. youkeDialogRef.value.handleShow();
  224. }
  225. }
  226. function duihuamaDuihuan() {
  227. if (loginFlag.value) {
  228. duihuanmaDialogRef.value.handleShow();
  229. } else {
  230. youkeDialogRef.value.handleShow();
  231. }
  232. }
  233. function duihuanmaBtn(data) {
  234. console.log('data', data);
  235. let req = {
  236. code: data
  237. }
  238. duihuanmaCode(req).then(res => {
  239. if (res.code == 0) {
  240. toast('兑换成功')
  241. const localList = cacheManager.get('auth').levelIdList || []
  242. const mergeList = [...new Set([...localList, ...res.data.levelIdList])]
  243. cacheManager.updateObject('auth', {
  244. levelIdList: mergeList
  245. })
  246. uni.redirectTo({
  247. url: '/pages/my/index'
  248. })
  249. } else {
  250. toast('兑换失败请重试或联系管理员')
  251. return false
  252. }
  253. }).catch(err => {
  254. })
  255. }
  256. function yinsizhengce() {
  257. agreeType.value = 'ystk'
  258. agreeContentDialogRef.value.handleShow();
  259. }
  260. function kefudianhua() {
  261. kefuDialogRef.value.handleShow();
  262. }
  263. function kefuBtn() {
  264. kefuDialogRef.value.handleClose();
  265. }
  266. // 游客弹窗---确定
  267. function ykConfirm() {
  268. uni.redirectTo({
  269. url: '/pages/login/index'
  270. });
  271. }
  272. function yingyongshezhi() {
  273. if (loginFlag.value) {
  274. const AuthCode = getUserIdentity();
  275. if (AuthCode == 'Visitor') {
  276. youkeDialogRef.value.handleShow();
  277. return;
  278. }
  279. uni.redirectTo({
  280. url: '/pages/my/yingyongshezhi'
  281. });
  282. } else {
  283. youkeDialogRef.value.handleShow();
  284. }
  285. }
  286. // 手机号码
  287. function telClick() {
  288. if (loginFlag.value) {
  289. telDialogFlag.value = true;
  290. } else {
  291. youkeDialogRef.value.handleShow();
  292. }
  293. }
  294. // 手机号码绑定
  295. function bindBtn() {
  296. telDialogFlag.value = false;
  297. myGetAuth()
  298. }
  299. // 关闭手机号码弹窗
  300. function telClose() {
  301. telDialogFlag.value = false;
  302. }
  303. // 关于我们
  304. function aboutClick() {
  305. if (loginFlag.value) {
  306. uni.redirectTo({
  307. url: '/pages/my/aboutPage'
  308. });
  309. } else {
  310. uni.redirectTo({
  311. url: `/pages/my/aboutPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
  312. });
  313. }
  314. }
  315. function sxtkClick() {
  316. if (loginFlag.value) {
  317. uni.redirectTo({
  318. url: '/pages/my/sxtkPage'
  319. });
  320. } else {
  321. youkeDialogRef.value.handleShow();
  322. }
  323. }
  324. function xxjlClick() {
  325. if (loginFlag.value) {
  326. uni.redirectTo({
  327. url: '/pages/my/xuexiJilu'
  328. });
  329. } else {
  330. youkeDialogRef.value.handleShow();
  331. }
  332. }
  333. function xxscClick() {
  334. uni.redirectTo({
  335. url: '/pages/my/xuexishichang'
  336. });
  337. }
  338. // 产品商城
  339. function cpscClick() {
  340. if (loginFlag.value) {
  341. uni.redirectTo({
  342. url: '/pages/mall/mallPage'
  343. });
  344. } else {
  345. uni.redirectTo({
  346. url: `/pages/mall/mallPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
  347. });
  348. }
  349. }
  350. // 订单
  351. function orderClick() {
  352. if (loginFlag.value) {
  353. uni.redirectTo({
  354. url: '/pages/pay/order'
  355. });
  356. } else {
  357. youkeDialogRef.value.handleShow();
  358. }
  359. }
  360. // 获取用户数据
  361. function getMyInfo() {
  362. myInfo({}).then(res => {
  363. myInfoData.userName = res.data.userName;
  364. myInfoData.credit = res.data.credit;
  365. myInfoData.nickName = res.data.nickName;
  366. if (res.data.nickName) {
  367. myInfoData.nickName = res.data.nickName;
  368. } else {
  369. myInfoData.nickName = '鹅状元';
  370. }
  371. if (res.data.icon) {
  372. myInfoData.icon = res.data.icon;
  373. } else {
  374. getUserImg(res.data.growthType)
  375. }
  376. })
  377. getMyCardList();
  378. }
  379. // 登录人员的cardlist
  380. function getMyCardList() {
  381. myCardList({}).then(res => {
  382. bannerArr.value = res.data;
  383. })
  384. }
  385. // 游客的cardList
  386. function getCommonCardList() {
  387. commonCardList({}).then(res => {
  388. bannerArr.value = res.data;
  389. })
  390. }
  391. // 获取用户头像
  392. function getUserImg(data) {
  393. switch (data) {
  394. case 0:
  395. myInfoData.icon = 'static/images/my/head-img0.png'
  396. break;
  397. case 1:
  398. myInfoData.icon = 'static/images/my/head-img1.png'
  399. break;
  400. case 2:
  401. myInfoData.icon = 'static/images/my/head-img2.png'
  402. break;
  403. case 3:
  404. myInfoData.icon = 'static/images/my/head-img3.png'
  405. break;
  406. default:
  407. myInfoData.icon = 'static/images/my/head-unlogin-img.png'
  408. break;
  409. }
  410. }
  411. // 点击card
  412. function hyqyBtn(data) {
  413. if (loginFlag.value) {
  414. uni.redirectTo({
  415. url: '/pages/mall/mallPage?cardId=' + data.id + '&subjectId=' + data.subjectId + '&from=myPage'
  416. })
  417. } else {
  418. uni.redirectTo({
  419. url: `/pages/mall/mallPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&cardId=${data.id}&subjectId=${data.subjectId}&tipFlag=${routerOpt.tipFlag}`
  420. });
  421. }
  422. }
  423. // 判断是否是游客
  424. function myGetAuth() {
  425. let LocalStorage = cacheManager.get('auth');
  426. if (LocalStorage) {
  427. // 非游客
  428. noYoukeFun()
  429. } else {
  430. youkeFun();
  431. }
  432. }
  433. // 游客
  434. function youkeFun() {
  435. // 获取广告
  436. getCommonCardList();
  437. levelId.value = routerOpt.levelId
  438. typeId.value = routerOpt.typeId
  439. subjectId.value = routerOpt.subjectId
  440. tipFlag.value = routerOpt.tipFlag
  441. // my游客
  442. loginFlag.value = false;
  443. myInfoData.userName = '游客';
  444. myInfoData.nickName = '鹅状元';
  445. myInfoData.icon = 'static/images/my/head-unlogin-img.png'
  446. }
  447. // 非游客
  448. function noYoukeFun() {
  449. loginFlag.value = true;
  450. getMyInfo();
  451. }
  452. function isIOSorAndroid() {
  453. const systemInfo = uni.getSystemInfoSync();
  454. console.log('systemInfo', systemInfo);
  455. if (systemInfo.platform == 'ios') {
  456. return currentPlatform.value = 'ios'
  457. } else {
  458. return currentPlatform.value = 'android'
  459. }
  460. }
  461. onLoad((options) => {
  462. if (!cacheManager.get('auth')) {
  463. // 游客
  464. routerOpt = options;
  465. isIOSorAndroid()
  466. } else {
  467. appleCode.value = cacheManager.get("auth").appleCode.toString()
  468. isIOSorAndroid()
  469. }
  470. })
  471. function checkWrong() {
  472. if (loginFlag.value) {
  473. const AuthCode = getUserIdentity();
  474. if (AuthCode == 'Visitor') {
  475. youkeDialogRef.value.handleShow();
  476. return;
  477. }
  478. uni.redirectTo({
  479. url: '/pages/wrong/index'
  480. })
  481. } else {
  482. youkeDialogRef.value.handleShow();
  483. }
  484. }
  485. </script>