index.vue 13 KB

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