setting.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. // #ifdef APP-PLUS
  228. if (uni.getSystemInfoSync().platform === 'android') {
  229. const main = plus.android.runtimeMainActivity();
  230. const NotificationManagerCompat = plus.android.importClass('androidx.core.app.NotificationManagerCompat');
  231. const Context = plus.android.importClass('android.content.Context');
  232. // 获取NotificationManagerCompat实例
  233. const notificationManager = NotificationManagerCompat.from(main);
  234. // 检查通知权限
  235. const areNotificationsEnabled = notificationManager.areNotificationsEnabled();
  236. if (areNotificationsEnabled) {
  237. uni.showToast({
  238. title: '通知权限已开启',
  239. icon: 'success'
  240. });
  241. } else {
  242. // 引导用户去设置页面开启通知
  243. this.$refs["DialogBox"]
  244. .confirm({
  245. title: "开启通知",
  246. content: "为了及时接收重要消息,请开启通知权限",
  247. DialogType: "inquiry",
  248. btn1: "取消",
  249. btn2: "确定",
  250. animation: 0,
  251. })
  252. .then(() => {
  253. const Intent = plus.android.importClass('android.content.Intent');
  254. const Settings = plus.android.importClass('android.provider.Settings');
  255. const Uri = plus.android.importClass('android.net.Uri');
  256. const intent = new Intent();
  257. intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
  258. intent.putExtra(Settings.EXTRA_APP_PACKAGE, main.getPackageName());
  259. main.startActivity(intent);
  260. });
  261. }
  262. } else {
  263. // iOS
  264. const UIApplication = plus.ios.import("UIApplication");
  265. const NSURL = plus.ios.import("NSURL");
  266. const setting = NSURL.URLWithString("app-settings:");
  267. const application = UIApplication.sharedApplication();
  268. application.openURL(setting);
  269. }
  270. // #endif
  271. // #ifdef H5
  272. uni.showToast({
  273. title: 'H5环境不支持此功能',
  274. icon: 'none'
  275. });
  276. // #endif
  277. } else if (page != "") {
  278. uni.navigateTo({
  279. url: page,
  280. });
  281. }
  282. },
  283. DelMem() {
  284. var that = this;
  285. this.$refs["DialogBox"]
  286. .confirm({
  287. title: "警告",
  288. content:
  289. "1、注销账号是不可逆操作,该账号下所有一切资料一旦注销无法恢复;\n2、注销后,你账号下所有权益将被清除。",
  290. DialogType: "inquiry",
  291. btn1: "否",
  292. btn2: "是",
  293. animation: 0,
  294. })
  295. .then(() => {
  296. uni.request({
  297. url: that.$apiHost + "/My/delete", //检测是否已绑定
  298. data: {
  299. uuid: getApp().globalData.uuid,
  300. },
  301. header: {
  302. "content-type": "application/json", //自定义请求头信息
  303. },
  304. success: (res) => {
  305. uni.removeStorageSync("wapptoken");
  306. uni.redirectTo({
  307. url: "/pages/login/login",
  308. });
  309. },
  310. });
  311. });
  312. },
  313. loadData() {
  314. console.log({
  315. uuid: getApp().globalData.uuid,
  316. skey: getApp().globalData.skey,
  317. });
  318. uni.request({
  319. url: this.$apiHost + "/Web/getinfo",
  320. data: {
  321. uuid: getApp().globalData.uuid,
  322. },
  323. header: {
  324. "content-type": "application/json",
  325. sign: getApp().globalData.headerSign,
  326. },
  327. success: (res) => {
  328. console.log("----:", res.data);
  329. this.myinfo = res.data;
  330. },
  331. complete: (com) => {
  332. // uni.hideLoading();
  333. },
  334. fail: (e) => {
  335. console.log("----e:", e);
  336. },
  337. });
  338. },
  339. EditNickname() {
  340. let that = this;
  341. this.$refs["DialogBox"]
  342. .confirm({
  343. title: "更改昵称",
  344. placeholder: "请输入修改的昵称",
  345. value: that.myinfo.nickname,
  346. DialogType: "input",
  347. animation: 0,
  348. })
  349. .then((res) => {
  350. if (res.value.length < 1) {
  351. uni.showToast({
  352. title: "请输入有效的昵称",
  353. icon: "none",
  354. });
  355. return;
  356. }
  357. that.myinfo.nickname = res.value;
  358. let obj2 = {
  359. nickname: res.value,
  360. };
  361. const postData = Object.assign(
  362. {},
  363. getApp().globalData.postHeader,
  364. obj2
  365. );
  366. uni.request({
  367. url: that.$apiHost + "/Gushi/editinfo", //检测是否已绑定
  368. data: postData,
  369. method: "POST",
  370. header: {
  371. "content-type": "application/json", //自定义请求头信息
  372. "Access-Control-Allow-Origin": "*",
  373. },
  374. success: (res) => {
  375. uni.showToast({
  376. title: res.data.str,
  377. icon: "none",
  378. });
  379. },
  380. });
  381. });
  382. },
  383. logout() {
  384. this.$refs["DialogBox"]
  385. .confirm({
  386. title: "提示",
  387. content: "确定要退出登录吗?",
  388. DialogType: "inquiry",
  389. btn1: "取消",
  390. btn2: "确定",
  391. animation: 0,
  392. })
  393. .then(() => {
  394. uni.removeStorageSync("wapptoken");
  395. uni.removeStorageSync("nickname");
  396. uni.removeStorageSync("avator");
  397. uni.removeStorageSync("mobile");
  398. uni.removeStorageSync("uuid");
  399. uni.removeStorageSync("user_id");
  400. uni.removeStorageSync("is_login");
  401. uni.redirectTo({
  402. url: "/pages/login/login",
  403. });
  404. });
  405. },
  406. },
  407. };
  408. </script>
  409. <style scoped lang="scss">
  410. @import "setting.scss";
  411. </style>