index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <template>
  2. <view class="ezy-my-page">
  3. <view class="my-head-box">
  4. <icon class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.userImg + ')'}"></icon>
  5. <view class="head-content-box">
  6. <text>{{myInfoData.userName}}</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. });
  166. let routerOpt = ref(false);
  167. let appleCode = ref(null);
  168. let currentPlatform = ref(null);
  169. const exitDialogRef = ref(null);
  170. const youkeDialogRef = ref(null);
  171. const zhuxiaoDialogRef = ref(null);
  172. const duihuanmaDialogRef = ref(null);
  173. const bannerArr = ref(null);
  174. const kefuDialogRef = ref(null);
  175. const kefuTitle = '提示';
  176. const kefuContent = '客服电话:17304117625';
  177. const exitLogin = () => {
  178. exitDialogRef.value.handleShow();
  179. }
  180. // 退出按钮
  181. const exitBtn = () => {
  182. if (loginFlag.value) {
  183. logout().then(res => {
  184. toast('退出登录成功')
  185. cacheManager.clearAll();
  186. uni.reLaunch({
  187. url: '/pages/login/index'
  188. });
  189. }).catch(err => {
  190. toast('退出登录失败,请稍后重试')
  191. })
  192. } else {
  193. uni.reLaunch({
  194. url: '/pages/login/index'
  195. });
  196. }
  197. }
  198. const zhuxiaoBtn = () => {
  199. let req = {
  200. }
  201. zhuxiao().then(res => {
  202. cacheManager.clearAll();
  203. toast('用户注销成功')
  204. uni.redirectTo({
  205. url: '/pages/login/index'
  206. });
  207. }).catch(err => {
  208. toast('失败,请稍后重试')
  209. })
  210. }
  211. function yonghuzhuxiao() {
  212. zhuxiaoDialogRef.value.handleShow();
  213. }
  214. function duihuamaDuihuan() {
  215. duihuanmaDialogRef.value.handleShow();
  216. }
  217. function duihuanmaBtn(data) {
  218. console.log('data', data);
  219. let req = {
  220. code: data
  221. }
  222. duihuanmaCode(req).then(res => {
  223. if (res.code == 0) {
  224. toast('兑换成功')
  225. const localList = cacheManager.get('auth').levelIdList || []
  226. const mergeList = [...new Set([...localList, ...res.data.levelIdList])]
  227. cacheManager.updateObject('auth', {
  228. levelIdList: mergeList
  229. })
  230. uni.redirectTo({
  231. url: '/pages/my/index'
  232. })
  233. } else {
  234. toast('兑换失败请重试或联系管理员')
  235. return false
  236. }
  237. }).catch(err => {
  238. })
  239. }
  240. function yinsizhengce() {
  241. agreeType.value = 'ystk'
  242. agreeContentDialogRef.value.handleShow();
  243. }
  244. function kefudianhua() {
  245. kefuDialogRef.value.handleShow();
  246. }
  247. function kefuBtn() {
  248. kefuDialogRef.value.handleClose();
  249. }
  250. // 游客弹窗---确定
  251. function ykConfirm() {
  252. uni.redirectTo({
  253. url: '/pages/login/index'
  254. });
  255. }
  256. function yingyongshezhi() {
  257. uni.redirectTo({
  258. url: '/pages/my/yingyongshezhi'
  259. });
  260. }
  261. // 手机号码
  262. function telClick() {
  263. if (loginFlag.value) {
  264. telDialogFlag.value = true;
  265. } else {
  266. youkeDialogRef.value.handleShow();
  267. }
  268. }
  269. // 手机号码绑定
  270. function bindBtn() {
  271. telDialogFlag.value = false;
  272. myGetAuth()
  273. }
  274. // 关闭手机号码弹窗
  275. function telClose() {
  276. telDialogFlag.value = false;
  277. }
  278. // 关于我们
  279. function aboutClick() {
  280. if (loginFlag.value) {
  281. uni.redirectTo({
  282. url: '/pages/my/aboutPage'
  283. });
  284. } else {
  285. uni.redirectTo({
  286. url: `/pages/my/aboutPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
  287. });
  288. }
  289. }
  290. function sxtkClick() {
  291. uni.redirectTo({
  292. url: '/pages/my/sxtkPage'
  293. });
  294. }
  295. function xxjlClick() {
  296. uni.redirectTo({
  297. url: '/pages/my/xuexiJilu'
  298. });
  299. }
  300. function xxscClick() {
  301. uni.redirectTo({
  302. url: '/pages/my/xuexishichang'
  303. });
  304. }
  305. // 产品商城
  306. function cpscClick() {
  307. if (loginFlag.value) {
  308. uni.redirectTo({
  309. url: '/pages/mall/mallPage'
  310. });
  311. } else {
  312. uni.redirectTo({
  313. url: `/pages/mall/mallPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
  314. });
  315. }
  316. }
  317. // 订单
  318. function orderClick() {
  319. if (loginFlag.value) {
  320. uni.redirectTo({
  321. url: '/pages/pay/order'
  322. });
  323. } else {
  324. youkeDialogRef.value.handleShow();
  325. }
  326. }
  327. // 获取用户数据
  328. function getMyInfo() {
  329. myInfo({}).then(res => {
  330. getUserImg(res.data.growthType)
  331. myInfoData.userName = res.data.userName;
  332. myInfoData.credit = res.data.credit;
  333. })
  334. getMyCardList();
  335. }
  336. // 登录人员的cardlist
  337. function getMyCardList() {
  338. myCardList({}).then(res => {
  339. bannerArr.value = res.data;
  340. })
  341. }
  342. // 游客的cardList
  343. function getCommonCardList() {
  344. commonCardList({}).then(res => {
  345. bannerArr.value = res.data;
  346. })
  347. }
  348. // 获取用户头像
  349. function getUserImg(data) {
  350. switch (data) {
  351. case 0:
  352. myInfoData.userImg = 'static/images/my/head-img0.png'
  353. break;
  354. case 1:
  355. myInfoData.userImg = 'static/images/my/head-img1.png'
  356. break;
  357. case 2:
  358. myInfoData.userImg = 'static/images/my/head-img2.png'
  359. break;
  360. case 3:
  361. myInfoData.userImg = 'static/images/my/head-img3.png'
  362. break;
  363. default:
  364. myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
  365. break;
  366. }
  367. }
  368. // 点击card
  369. function hyqyBtn(data) {
  370. if (loginFlag.value) {
  371. uni.redirectTo({
  372. url: '/pages/mall/mallPage?cardId=' + data.id + '&subjectId=' + data.subjectId + '&from=myPage'
  373. })
  374. } else {
  375. uni.redirectTo({
  376. url: `/pages/mall/mallPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&cardId=${data.id}&subjectId=${data.subjectId}&tipFlag=${routerOpt.tipFlag}`
  377. });
  378. }
  379. }
  380. // 判断是否是游客
  381. function myGetAuth() {
  382. let LocalStorage = cacheManager.get('auth');
  383. if (LocalStorage) {
  384. // 非游客
  385. noYoukeFun()
  386. } else {
  387. youkeFun();
  388. }
  389. }
  390. // 游客
  391. function youkeFun() {
  392. // 获取广告
  393. getCommonCardList();
  394. levelId.value = routerOpt.levelId
  395. typeId.value = routerOpt.typeId
  396. subjectId.value = routerOpt.subjectId
  397. tipFlag.value = routerOpt.tipFlag
  398. // my游客
  399. loginFlag.value = false;
  400. myInfoData.userName = '游客';
  401. myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
  402. }
  403. // 非游客
  404. function noYoukeFun() {
  405. loginFlag.value = true;
  406. getMyInfo();
  407. }
  408. function isIOSorAndroid() {
  409. const systemInfo = uni.getSystemInfoSync();
  410. console.log('systemInfo', systemInfo);
  411. if (systemInfo.platform == 'ios') {
  412. return currentPlatform.value = 'ios'
  413. } else {
  414. return currentPlatform.value = 'android'
  415. }
  416. }
  417. onLoad((options) => {
  418. if (!cacheManager.get('auth')) {
  419. // 游客
  420. routerOpt = options;
  421. } else {
  422. appleCode.value = cacheManager.get("auth").appleCode.toString()
  423. isIOSorAndroid()
  424. }
  425. })
  426. function checkWrong() {
  427. if (loginFlag.value) {
  428. const AuthCode = getUserIdentity();
  429. if (AuthCode == 'Visitor') {
  430. youkeDialogRef.value.handleShow();
  431. return;
  432. }
  433. uni.redirectTo({
  434. url: '/pages/wrong/index'
  435. })
  436. } else {
  437. youkeDialogRef.value.handleShow();
  438. }
  439. }
  440. </script>