setting.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view>
  3. <ujp-navbar title="设置"></ujp-navbar> <view class="group">
  4. <view class="userCell-item">
  5. <view class="userCell-title">
  6. <p class="oldTextjp" oldstyle="font-size: 18px;">长辈模式</p>
  7. </view>
  8. <view class="userCell-content " >
  9. <view class="value">
  10. <view class="text oldTextjp2" oldstyle="font-size: 16px;">
  11. 字体更大 看得清
  12. </view>
  13. <u-switch v-model="checked" active-color="#00E266" @change="checkedChange"></u-switch>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="userCell-item" v-if="personInfo.memberLevel==3">
  18. <view class="userCell-title">
  19. <p class="oldTextjp" oldstyle="font-size: 18px;">快捷充电</p>
  20. </view>
  21. <view class="userCell-content " >
  22. <view class="value">
  23. <view class="text oldTextjp2" oldstyle="font-size: 16px;">
  24. 扫码即充 充满自停
  25. </view>
  26. <u-switch v-model="checked2" active-color="#00E266" @change="checkedChange2"></u-switch>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="userCell-item" @click="gotoUrl('pages/user/logout')">
  31. <view class="userCell-title">
  32. <p class="oldTextjp" oldstyle="font-size: 18px;">注销账号</p>
  33. </view>
  34. <view class="userCell-content " >
  35. <text class="ff oldTextjp2" oldstyle="font-size: 16px;">注销后无法恢复,请谨慎操作 </text>
  36. <text class="iconfont">&#xe600;</text>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="logout-btn oldTextjp" oldstyle="font-size:18px" @click="signOut">
  41. 退出帐号
  42. </view>
  43. <view>
  44. <u-modal v-model="show" @confirm="confirm" confirm-color="#FF3D00" :show-cancel-button="true" ref="uModal" :asyncClose="true" :title="title"
  45. :content="content" :content-style="{color: '#333333'}"></u-modal>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import * as userApi from '@/apis/user.js'
  51. import * as API from '@/apis/index.js'
  52. import * as loginApi from '@/apis/login.js'
  53. export default {
  54. data() {
  55. return {
  56. show: false,
  57. title: '退出账号',
  58. content: '是否退出当前账号?',
  59. userId: '',
  60. userPhone: '',
  61. checked:false,
  62. checked2:false,
  63. valueStyle: {
  64. color:'#ff3300',
  65. },
  66. valueStyle2: {
  67. color: '#777777',
  68. textAlign: 'left',
  69. marginLeft: '8px'
  70. },
  71. titleStyle: {
  72. fontWeight: 'bold',
  73. fontSize: '18px',
  74. },
  75. fontMode: '',
  76. personInfo:{}
  77. }
  78. },
  79. onReady() {
  80. if(this.carhelp.get("getElderModeClass") == "长辈模式") {
  81. this.checked = true;
  82. } else {
  83. this.checked = false;
  84. }
  85. this.personInfo = this.carhelp.getPersonInfo()
  86. this.$forceUpdate()
  87. if(this.personInfo.fontMode=="1"){
  88. this.checked = true;
  89. this.carhelp.set("getElderModeClass","长辈模式")
  90. }
  91. if(this.personInfo.quickCharging){
  92. this.checked2 = true;
  93. }
  94. },
  95. methods: {
  96. getUserInfo() {
  97. uni.showLoading({
  98. title: "加载中",
  99. mask: true,
  100. })
  101. loginApi.findByOpenId({
  102. openId: this.carhelp.getOpenId()
  103. }).then((res) => {
  104. uni.hideLoading();
  105. if (res.code == 200&&res.result) {
  106. var token = res ? res.data.token : '';
  107. this.personInfo=res.data.regUser
  108. this.carhelp.setPersonInfo(res.data.regUser );
  109. this.carhelp.setToken(token);
  110. this.carhelp.setPersonInfoPlus(res.data);
  111. console.log("setPersonInfoPlus")
  112. }
  113. }).catch(error => {
  114. this.carhelp.logoff()
  115. uni.showToast({
  116. title: error,
  117. icon: "none"
  118. })
  119. })
  120. },
  121. checkedChange2() {
  122. API.changeQuickCharging({qucikStatus: this.checked2?1:0}).then((res) => {
  123. this.getUserInfo()
  124. }).catch(error => {
  125. uni.showToast({
  126. title: error,
  127. icon: "none"
  128. })
  129. })
  130. },
  131. checkedChange() {
  132. if(this.checked) {
  133. this.carhelp.set("getElderModeClass", "长辈模式");
  134. this.fontMode = '1';
  135. } else {
  136. this.carhelp.set("getElderModeClass", "标准模式");
  137. this.fontMode = '0';
  138. }
  139. API.changeFont({fontMode: this.fontMode}).then((res) => {
  140. this.getUserInfo()
  141. }).catch(error => {
  142. uni.showToast({
  143. title: error,
  144. icon: "none"
  145. })
  146. })
  147. },
  148. signOut() {
  149. this.show = true;
  150. },
  151. confirm() {
  152. uni.showLoading({
  153. title: "加载中",
  154. mask: true,
  155. })
  156. userApi.logout().then((res) => {
  157. uni.hideLoading();
  158. this.show = false;
  159. this.carhelp.logoff()
  160. uni.redirectTo({
  161. url: '/pages/login/login'
  162. })
  163. }).catch(error => {
  164. uni.showToast({
  165. title: error,
  166. icon: "none"
  167. })
  168. })
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. .logout-btn{
  175. background-color: #fff;
  176. padding: 12px 0;
  177. text-align: center;
  178. margin-top: 12px;
  179. }
  180. .group{
  181. background-color: #fff;
  182. margin-top: 12px;
  183. }
  184. .ff{
  185. color: #FF0000;
  186. }
  187. .userCell-item {
  188. display: flex;
  189. border-bottom: 1px solid rgba(241, 241, 241, 100);
  190. align-items: center;
  191. padding: 8px 16px 8px 0px;
  192. margin-left: 8px;
  193. .userCell-title {
  194. font-size: 16px;
  195. display: flex;
  196. margin-right: 8px;
  197. p {
  198. margin-left: 8px;
  199. font-size: 16px;
  200. line-height: 28px;
  201. color: #1a1a1a;
  202. }
  203. }
  204. .userCell-content {
  205. display: flex;
  206. flex: 1;
  207. justify-content: space-between;
  208. margin-left: 40rpx;
  209. color: #777777;
  210. font-size: 12px;
  211. line-height: 20px;
  212. .iconfont{
  213. font-size: 24px;
  214. margin: auto 0;
  215. color: #b3b3b3
  216. }
  217. }
  218. .value {
  219. display: flex;
  220. justify-content: space-between;
  221. flex: 1;
  222. .text {
  223. line-height: 28px;
  224. // margin-right: 20vw;
  225. }
  226. }
  227. .u-switch {
  228. float: right;
  229. width: 48px;
  230. height: 24px;
  231. vertical-align: middle;
  232. margin-left: 8px;
  233. }
  234. /deep/.u-switch__node {
  235. width: 24px !important;
  236. height: 24px !important;
  237. }
  238. }
  239. .switcher-mode{
  240. background-color: #fff;
  241. height: 44px;
  242. line-height: 44px;
  243. display: flex;
  244. justify-content: space-between;
  245. padding: 0 14px;
  246. text{
  247. font-size: 12px;
  248. color: rgba(119, 119, 119, 100);
  249. margin-left: 8px;
  250. }
  251. .switch-box{
  252. padding-top: 8px;
  253. }
  254. .switch{
  255. width: 40px;
  256. height: 22px;
  257. }
  258. /deep/.u-switch__node{
  259. width: 20px !important;
  260. height: 20px !important;
  261. }
  262. }
  263. </style>