setting.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <view class="page">
  3. <view class="list_info">
  4. <view class="">
  5. <!-- 基础设置组 -->
  6. <view class="group-header">基础设置</view>
  7. <view
  8. class="item basic"
  9. v-for="(item, index) in basicSettings"
  10. :key="item.name + index"
  11. @click="goPage(item.path)"
  12. >
  13. <view class="item-left">
  14. <image class="icon" :src="item.icon" mode="widthFix"></image>
  15. <text>{{ item.name }}</text>
  16. </view>
  17. <view class="item-right">
  18. <switch
  19. v-if="item.switch == 1"
  20. checked
  21. class="custom-switch"
  22. color="#acf934"
  23. style="transform: scale(0.7)"
  24. />
  25. <image
  26. v-else
  27. class="arrow"
  28. src="../../static/me/arrow_right_gray.png"
  29. mode="widthFix"
  30. ></image>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="">
  35. <!-- 更多设置组 -->
  36. <view class="group-header" style="margin-top: 20rpx">更多</view>
  37. <view
  38. class="item more"
  39. v-for="(item, index) in moreSettings"
  40. :key="index + item.name"
  41. @click="goPage(item.path, item)"
  42. >
  43. <view class="item-left">
  44. <image class="icon" :src="item.icon" mode="widthFix"></image>
  45. <text>{{ item.name }}</text>
  46. </view>
  47. <view class="item-right">
  48. <switch
  49. v-if="item.switch == 1"
  50. color="#acf934"
  51. @change="switch1Change"
  52. :checked="isContentRecommendation"
  53. class="custom-switch"
  54. style="transform: scale(0.7)"
  55. />
  56. <image
  57. v-else
  58. class="arrow"
  59. src="../../static/me/arrow_right_gray.png"
  60. mode="widthFix"
  61. ></image>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <!-- 版本信息 -->
  67. <view class="version-info">
  68. <text>版本号 {{ version }}</text>
  69. </view>
  70. <!-- 退出登录按钮 -->
  71. <view class="btn_submit" @click="logout">退出登录</view>
  72. <DialogBox ref="DialogBox"></DialogBox>
  73. <CustomerServicePopup ref="customerServicePopup"></CustomerServicePopup>
  74. </view>
  75. </template>
  76. <script>
  77. import CustomerServicePopup from "@/components/CustomerServicePopup/CustomerServicePopup.vue";
  78. import { getStorage, setStorage, removeStorage } from "@/common/util.js";
  79. export default {
  80. components: { CustomerServicePopup },
  81. data() {
  82. return {
  83. title: "",
  84. sel: 1,
  85. myinfo: {},
  86. version: "",
  87. basicSettings: [
  88. {
  89. name: "账户与安全",
  90. desc: "",
  91. path: "/pages/my/security",
  92. icon: "../../static/me/wd_icon_zhanghuyuanquan.png",
  93. propup: "",
  94. },
  95. {
  96. name: "基本资料",
  97. desc: "",
  98. path: "/pages/my/editInfo",
  99. icon: "../../static/me/wd_icon_jibenziliao.png",
  100. propup: "",
  101. },
  102. {
  103. name: "青少年模式",
  104. switch: 0,
  105. desc: "",
  106. // 'path': '/pages/my/idcheck',实名认证
  107. path: "/pages/my/adolescent",
  108. icon: "../../static/me/wd_icon_qingshaonianmoshi.png",
  109. propup: "",
  110. },
  111. ],
  112. moreSettings: [
  113. {
  114. name: "通知设置",
  115. desc: "",
  116. path: "pushSet",
  117. icon: "../../static/me/wd_icon_tonzhishezhi.png",
  118. propup: "",
  119. },
  120. {
  121. name: "服务条款",
  122. desc: "",
  123. path: "/pages/AboutUs/xieyi",
  124. icon: "../../static/me/wd_icon_fuwutiaokuan.png",
  125. propup: "",
  126. },
  127. {
  128. name: "接收内容推荐",
  129. switch: 1,
  130. desc: "",
  131. path: "",
  132. icon: "../../static/me/wd_icon_jieshouneirongtuijian.png",
  133. propup: "",
  134. },
  135. {
  136. name: "联系客服",
  137. desc: "",
  138. path: "kefu",
  139. icon: "../../static/me/wd_icon_lianxikefu.png",
  140. propup: "customPopup",
  141. },
  142. ],
  143. isContentRecommendation: true,
  144. };
  145. },
  146. onLoad() {
  147. this.getAppVersion();
  148. },
  149. onShow() {
  150. this.loadData();
  151. //
  152. var isContentRecommendation = getStorage("isContentRecommendation");
  153. if (isContentRecommendation != undefined) {
  154. this.isContentRecommendation =
  155. isContentRecommendation == "false" ? false : true;
  156. } else {
  157. setStorage("isContentRecommendation", true);
  158. }
  159. },
  160. methods: {
  161. openCustomPopup() {
  162. this.$refs.customerServicePopup.$refs.customPopup.open();
  163. },
  164. getAppVersion() {
  165. uni.getSystemInfo({
  166. success: (info) => {
  167. // app系统环境
  168. let appPlatform = info.platform;
  169. console.log("appPlatform", info);
  170. // #ifdef H5
  171. this.version = "V" + info.appVersion;
  172. // #endif
  173. // #ifdef APP-PLUS
  174. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  175. this.version = "V" + wgtinfo.version;
  176. });
  177. // #endif
  178. },
  179. });
  180. },
  181. switch1Change(e) {
  182. setStorage("isContentRecommendation", e.detail.value);
  183. },
  184. onBack() {},
  185. chkSel() {
  186. if (this.sel == 1) {
  187. this.sel = 0;
  188. } else {
  189. this.sel = 1;
  190. }
  191. },
  192. goPage(page) {
  193. if (page == "delete") {
  194. this.DelMem();
  195. } else if (page == "yszc") {
  196. // #ifdef APP-PLUS
  197. plus.runtime.openURL("https://e.zhichao.art/web/yszc.php"); // plus.runtime.openWeb(href);
  198. // #endif
  199. // #ifdef H5
  200. window.open("https://e.zhichao.art/web/yszc.php");
  201. // #endif
  202. } else if (page == "kefu") {
  203. // let that = this;
  204. // // #ifdef APP-PLUS
  205. // plus.share.getServices(res => {
  206. // const wechat = res.find(i => i.id === 'weixin')
  207. // if (wechat) {
  208. // wechat.openCustomerServiceChat({
  209. // corpid: 'wwbc06aa8311b6ac08',
  210. // // url: 'https://work.weixin.qq.com/kfid/kfc4b0bcb4038d00a50'
  211. // url: that.myinfo.wxkf
  212. // }, src => {
  213. // console.log("success:")
  214. // }, err => {
  215. // console.log("error:")
  216. // })
  217. // } else {
  218. // uni.showToast({
  219. // title: '没有检测到微信,请先安装',
  220. // icon: "error"
  221. // });
  222. // }
  223. // });
  224. // // #endif
  225. this.openCustomPopup();
  226. } else if (page == "pushSet") {
  227. // 添加引导用户打开通知权限的逻辑
  228. } else if (page != "") {
  229. uni.navigateTo({
  230. url: page,
  231. });
  232. }
  233. },
  234. DelMem() {
  235. var that = this;
  236. this.$refs["DialogBox"]
  237. .confirm({
  238. title: "警告",
  239. content:
  240. "1、注销账号是不可逆操作,该账号下所有一切资料一旦注销无法恢复;\n2、注销后,你账号下所有权益将被清除。",
  241. DialogType: "inquiry",
  242. btn1: "否",
  243. btn2: "是",
  244. animation: 0,
  245. })
  246. .then(() => {
  247. uni.request({
  248. url: that.$apiHost + "/My/delete", //检测是否已绑定
  249. data: {
  250. uuid: getApp().globalData.uuid,
  251. },
  252. header: {
  253. "content-type": "application/json", //自定义请求头信息
  254. },
  255. success: (res) => {
  256. uni.removeStorageSync("wapptoken");
  257. uni.redirectTo({
  258. url: "/pages/login/login",
  259. });
  260. },
  261. });
  262. });
  263. },
  264. loadData() {
  265. console.log({
  266. uuid: getApp().globalData.uuid,
  267. skey: getApp().globalData.skey,
  268. });
  269. uni.request({
  270. url: this.$apiHost + "/Web/getinfo",
  271. data: {
  272. uuid: getApp().globalData.uuid,
  273. },
  274. header: {
  275. "content-type": "application/json",
  276. sign: getApp().globalData.headerSign,
  277. },
  278. success: (res) => {
  279. console.log("----:", res.data);
  280. this.myinfo = res.data;
  281. },
  282. complete: (com) => {
  283. // uni.hideLoading();
  284. },
  285. fail: (e) => {
  286. console.log("----e:", e);
  287. },
  288. });
  289. },
  290. EditNickname() {
  291. let that = this;
  292. this.$refs["DialogBox"]
  293. .confirm({
  294. title: "更改昵称",
  295. placeholder: "请输入修改的昵称",
  296. value: that.myinfo.nickname,
  297. DialogType: "input",
  298. animation: 0,
  299. })
  300. .then((res) => {
  301. if (res.value.length < 1) {
  302. uni.showToast({
  303. title: "请输入有效的昵称",
  304. icon: "none",
  305. });
  306. return;
  307. }
  308. that.myinfo.nickname = res.value;
  309. let obj2 = {
  310. nickname: res.value,
  311. };
  312. const postData = Object.assign(
  313. {},
  314. getApp().globalData.postHeader,
  315. obj2
  316. );
  317. uni.request({
  318. url: that.$apiHost + "/Gushi/editinfo", //检测是否已绑定
  319. data: postData,
  320. method: "POST",
  321. header: {
  322. "content-type": "application/json", //自定义请求头信息
  323. "Access-Control-Allow-Origin": "*",
  324. },
  325. success: (res) => {
  326. uni.showToast({
  327. title: res.data.str,
  328. icon: "none",
  329. });
  330. },
  331. });
  332. });
  333. },
  334. logout() {
  335. this.$refs["DialogBox"]
  336. .confirm({
  337. title: "提示",
  338. content: "确定要退出登录吗?",
  339. DialogType: "inquiry",
  340. btn1: "取消",
  341. btn2: "确定",
  342. animation: 0,
  343. })
  344. .then(() => {
  345. uni.removeStorageSync("wapptoken");
  346. uni.removeStorageSync("nickname");
  347. uni.removeStorageSync("avator");
  348. uni.removeStorageSync("mobile");
  349. uni.removeStorageSync("uuid");
  350. uni.removeStorageSync("user_id");
  351. uni.removeStorageSync("is_login");
  352. uni.redirectTo({
  353. url: "/pages/login/login",
  354. });
  355. });
  356. },
  357. },
  358. };
  359. </script>
  360. <style scoped lang="scss">
  361. @import "setting.scss";
  362. </style>