setting.vue 12 KB

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