yingyongshezhi.vue 10 KB

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