login.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  1. <template>
  2. <view>
  3. <!-- 状态栏 -->
  4. <!-- 公共组件-每个页面必须引入 -->
  5. <public-module></public-module>
  6. <app-update ref="app_update"></app-update>
  7. <!-- 欢迎语 -->
  8. <view class="dis j-end a-c">
  9. <image src="../../static/image/login/2.png" mode="" style="height: 280px;width: calc(100% - 16px);"
  10. :style="{marginTop:marginTop}">
  11. </image>
  12. </view>
  13. <view class="" style="margin-top: -260rpx;">
  14. <u-tabs :list="list" :is-scroll="true" :current="current" @change="change"
  15. style="background: transparent;margin-bottom: 40rpx;"></u-tabs>
  16. <!-- 登录区域Start -->
  17. <view class="mx-3">
  18. <!-- 账号密码登录 false代表账号密码登录 -->
  19. <template v-if="current==0">
  20. <view class="mt-2 position-relative border-bottom">
  21. <view class="position-absolute d-flex a-center j-center left-0 top-0 font-weight"
  22. style="height: 100%;">
  23. <image src="../../static/image/login/zhanghao.png" mode=""
  24. style="width: 18px;height: 18px;">
  25. </image>
  26. </view>
  27. <input type="text" v-model="username" class="uni-input common-input" maxlength="17"
  28. placeholder="请输入会员号" style="padding-left: 56rpx;background: transparent;" />
  29. </view>
  30. <view class="mt-2 position-relative border-bottom">
  31. <view class="position-absolute d-flex a-center j-center left-0 top-0 font-weight"
  32. style="height: 100%;">
  33. <image src="../../static/image/login/mima.png" mode="" style="width: 18px;height: 18px;">
  34. </image>
  35. </view>
  36. <input type="text" :password="isHidePassword" v-model="password" class="uni-input common-input"
  37. placeholder="请输入密码" style="padding-right: 200rpx;padding-left: 56rpx;" maxlength="15" />
  38. <view class=" position-absolute top-0 right-0 d-flex a-center j-center"
  39. style="width: 200rpx;height: 100%;">
  40. <image
  41. :src="isHidePassword?'../../static/image/login/biyan.png':'../../static/image/login/zhengyan.png'"
  42. @tap="isHidePassword = !isHidePassword" mode="" style="width: 18px;height: 18px;">
  43. </view>
  44. </view>
  45. <view class="mt-2 position-relative border-bottom">
  46. <view class="position-absolute d-flex a-center j-center left-0 top-0 font-weight"
  47. style="height: 100%;">
  48. <image src="../../static/image/login/yanzhengma.png" mode=""
  49. style="width: 18px;height: 18px;">
  50. </image>
  51. </view>
  52. <input type="text" v-model="imgcode" class="uni-input common-input" maxlength="5"
  53. placeholder="请输入验证码" style="padding-right: 200rpx;padding-left: 56rpx;" />
  54. <image style="height: 80%;padding-top: 4rpx;width: 200rpx;" mode="aspectFill"
  55. class="position-absolute top-0 right-0 d-flex a-center j-center text-light-muted"
  56. :src="imgcodesrc" @tap="refreshCaptcha"></image>
  57. </view>
  58. </template>
  59. <!-- 手机验证码登录 true代表手机验证码登录 -->
  60. <template v-else>
  61. <view class="mt-2 position-relative border-bottom">
  62. <view class="position-absolute d-flex a-center j-center left-0 top-0 font-weight"
  63. style="height: 100%;">
  64. <image src="../../static/image/login/shoujihao.png" mode=""
  65. style="width: 18px;height: 18px;">
  66. </image>
  67. </view>
  68. <input type="text" v-model="phone" class="uni-input common-input" style="padding-left: 56rpx;"
  69. placeholder="手机号" />
  70. </view>
  71. <view class="mt-2 position-relative border-bottom">
  72. <view class="position-absolute d-flex a-center j-center left-0 top-0 font-weight"
  73. style="height: 100%;">
  74. <image src="../../static/image/login/yanzhengma.png" mode=""
  75. style="width: 18px;height: 18px;">
  76. </image>
  77. </view>
  78. <input type="text" v-model="checknum" class="uni-input common-input" maxlength="4"
  79. style="padding-right:120px;padding-left: 56rpx;" placeholder="请输入验证码" />
  80. <view class="position-absolute top-0 right-0 d-flex a-center j-center text-light-muted"
  81. style="width: 240rpx;height: 100%;" @tap="getCheckNum">
  82. <view class="d-flex a-center j-center "
  83. :class="!codetime?'yanzhengmaView1 text-color':'yanzhengmaView2'">
  84. {{!codetime?'获取验证码':codetime+' S'+'后重新获取'}}
  85. </view>
  86. </view>
  87. </view>
  88. </template>
  89. <button class="my-3 d-flex a-center j-center font-weight bg-color" :loading="loading"
  90. :class="{'bg-hover-color':disabled}" type="primary" @tap="submit" :disabled="disabled"
  91. style="letter-spacing: 20rpx;">登录</button>
  92. <view class=" dis a-start text-light-muted">
  93. <u-checkbox v-model="checked" style="margin-top: 4px;"></u-checkbox>
  94. <text>
  95. 我阅读并同意 <text @tap="nav('/pages/login/xieyi')" class="text-color">用户协议</text>和<text
  96. class="text-color" @tap="nav('/pages/login/mimi')">隐私政策</text>,未注册用户将自动注册
  97. </text>
  98. </view>
  99. <!-- #ifdef APP -->
  100. <view class="third_party_login_box">
  101. <view class="third_party_title"><text>第三方登录</text></view>
  102. <view class="third_party_content flex-wrap">
  103. <image src="../../static/image/login/wx.png" @click="onWxAppLogin" mode="aspectFit"></image>
  104. <image src="../../static/image/login/zf.png" @click="onzfbAppLogin" mode="aspectFit"></image>
  105. </view>
  106. </view>
  107. <!-- #endif -->
  108. </view>
  109. </view>
  110. <u-toast ref="uToast" />
  111. <u-popup v-model="show" border-radius="14" mode="center" width="70%">
  112. <view class="shu1 shili">
  113. <text>温馨提示</text>
  114. <text>是否更新账号密码?</text>
  115. </view>
  116. <view class="heng shili_btn">
  117. <view class="heng1" @click="quxiao">取消</view>
  118. <view class="heng1" @click="queren" style="background-color: orangered;">确认</view>
  119. </view>
  120. </u-popup>
  121. <u-popup v-model="privacyPolicyValidation" mode="bottom" border-radius="12">
  122. <view class="privacyPolicyValidationclass dis f-c a-start">
  123. <text class="title">用户协议及隐私政策</text>
  124. <text class="content">未注册的用户将自动注册,请您认真阅读 <text @tap="nav('/pages/login/xieyi')"
  125. class="text-color">《用户协议》</text>和<text class="text-color"
  126. @tap="nav('/pages/login/mimi')">《隐私政策》</text>的全部条款,接受后可开始使用本产品 </text>
  127. <view class="dis a-c j-s" style="margin-top: 10px;width: 100%;">
  128. <u-button type="default" @click="butongyi">不同意</u-button>
  129. <u-button type="primary" style="width: 70%;" @click="tongyi">同意并继续</u-button>
  130. </view>
  131. </view>
  132. </u-popup>
  133. </view>
  134. </template>
  135. <script>
  136. import appUpdate from "@/components/yzhua006-update/app-update.vue"; //app更新组件
  137. import md5 from '@/plugins/md5';
  138. let clear;
  139. import {
  140. mapState,
  141. mapMutations
  142. } from 'vuex';
  143. import DB from "@/common/sqlite";
  144. export default {
  145. components: {
  146. appUpdate
  147. },
  148. data() {
  149. return {
  150. privacyPolicyValidation: false,
  151. loginMethod: "weixin",
  152. checked: false,
  153. list: [{
  154. name: '账号登录'
  155. }, {
  156. name: '短信登录'
  157. }],
  158. current: 0,
  159. isLoading: false,
  160. show: false,
  161. contentSlot: true,
  162. status: false, //false代表账号密码登录,true代表手机验证码登录
  163. disabled: true, //登录按钮是否可用
  164. loading: false, //是否显示按钮加载状态
  165. username: "", //登录用户名
  166. password: "", //登录密码
  167. imgcode: "", //图片验证码0
  168. imgcodesrc: "", //验证码图片
  169. isHidePassword: true, //是否隐藏密码
  170. phone: "", //登录手机号
  171. checknum: "", //登录验证码
  172. captchaId: "",
  173. codetime: 0, //验证码获取倒计时
  174. code: "", //用户code
  175. listData: [],
  176. marginTop: "",
  177. };
  178. },
  179. onReady() {
  180. this.isLoading = true;
  181. },
  182. beforeCreate() {
  183. setTimeout(() => {
  184. this.$refs.app_update.update(); //调用子组件检查更新方法
  185. setTimeout(() => {
  186. if (this.$refs.app_update.popup_show == true && this.$refs.app_update.force == true) {}
  187. }, 100)
  188. }, 500)
  189. },
  190. //第一次加载
  191. async onLoad(e) {
  192. // #ifdef APP-PLUS
  193. this.openSQL();
  194. this.selectTableData();
  195. // this.deleteTableData();
  196. // #endif
  197. },
  198. watch: {
  199. username(val) {
  200. this.username = this.username.toUpperCase();
  201. this.OnBtnChange();
  202. },
  203. password(val) {
  204. this.OnBtnChange();
  205. },
  206. imgcode(val) {
  207. this.OnBtnChange();
  208. },
  209. phone(val) {
  210. this.OnBtnChange();
  211. },
  212. checknum(val) {
  213. this.OnBtnChange();
  214. }
  215. },
  216. mounted() {
  217. // //取出缓存中的账号、密码
  218. const HBusername = uni.getStorageSync('username');
  219. const HBpassword = uni.getStorageSync('password');
  220. // //有账号、密码就赋值给文本,没有就清空
  221. this.username = HBusername;
  222. this.password = HBpassword;
  223. const systemInfo = uni.getSystemInfoSync();
  224. const screenHeight = systemInfo.screenHeight;
  225. if (screenHeight > 700) {
  226. this.marginTop = "25%";
  227. } else {
  228. this.marginTop = "7%";
  229. }
  230. },
  231. onShow() {
  232. this.refreshCaptcha();
  233. uni.getClipboardData({
  234. success: (res) => {
  235. let id = (res.data.replace(/(^\s*)|(\s*$)/g, "")).toUpperCase();
  236. if ((id.length == 17) && (id.indexOf('99') == 0) && (id.indexOf('D') >
  237. 0) && (id.indexOf(
  238. 'M') > 0) && (id !== this.username)) {
  239. uni.showModal({
  240. content: '是否自动填充会员号',
  241. cancelText: '否',
  242. confirmText: '是',
  243. success: (res1) => {
  244. if (res1.confirm) {
  245. this.username = id;
  246. }
  247. }
  248. });
  249. }
  250. }
  251. })
  252. //#ifdef APP-PLUS
  253. let args = plus.runtime.arguments;
  254. if (args) {
  255. plus.runtime.arguments = null; //进入之后就把urlscheme清空要不然下一次oushow时还会执行
  256. // 处理args参数,如直达到某新页面等
  257. //通过code请求获取user_id
  258. var authCode = args.split("=")[1];
  259. if (authCode != undefined && authCode != "" && authCode != null) {
  260. this.$login({
  261. url: "/alipay/login",
  262. data: {
  263. code: authCode,
  264. }
  265. }).then(res => {
  266. return uni.showToast({
  267. title: res.msg,
  268. icon: 'none'
  269. });
  270. return;
  271. })
  272. }
  273. }
  274. //#endif
  275. },
  276. onUnload() {
  277. this.closeSQL();
  278. },
  279. computed: {
  280. ...mapState(["userLoginId", "loginStatus"])
  281. },
  282. //方法
  283. methods: {
  284. ...mapMutations(['setUserInfo']),
  285. // 跳转页面
  286. change(index) {
  287. this.current = index;
  288. },
  289. nav(url) {
  290. uni.navigateTo({
  291. url: url
  292. });
  293. },
  294. butongyi() {
  295. this.privacyPolicyValidation = false;
  296. return uni.showToast({
  297. title: '请先同意协议',
  298. icon: 'none'
  299. });
  300. },
  301. tongyi() {
  302. this.privacyPolicyValidation = false;
  303. this.checked = true;
  304. this[this.loginMethod]();
  305. },
  306. // 图片验证码
  307. refreshCaptcha() {
  308. let randnum = Math.floor(Math.random() * (1000000 - 1 + 1)) + 1
  309. this.imgcodesrc = this.$base.baseUrl + "/captchaById?t=" + new Date().getTime() +
  310. '&captchaId=' + randnum;
  311. this.captchaId = randnum;
  312. },
  313. // 切换登录状态
  314. changeStatus() {
  315. uni.hideKeyboard();
  316. this.initInput();
  317. this.status = !this.status;
  318. this.refreshCaptcha();
  319. },
  320. // 初始化表单
  321. initInput() {
  322. this.username = '';
  323. this.password = '';
  324. this.phone = '';
  325. this.checknum = '';
  326. this.imgcode = "";
  327. },
  328. // 改变按钮状态
  329. OnBtnChange() {
  330. if ((this.username && this.password && this.imgcode) || (this.phone && this.checknum)) {
  331. this.disabled = false;
  332. return;
  333. }
  334. this.disabled = true;
  335. },
  336. // 获取验证码
  337. async getCheckNum() {
  338. uni.hideKeyboard();
  339. if (this.codetime > 0) return;
  340. // 验证手机号合法性
  341. if (!this.phone) {
  342. return uni.showToast({
  343. title: '请输入手机号',
  344. icon: 'none'
  345. });
  346. }
  347. if (!this.$base.phoneRegular.test(this.phone)) {
  348. return uni.showToast({
  349. title: '请输入正确的手机号码',
  350. icon: 'none'
  351. });
  352. }
  353. // 请求服务器,发送验证码
  354. let res = await this.$http.get('/sendMsg', {
  355. phone: this.phone,
  356. type: "0"
  357. });
  358. // 请求失败处理
  359. if (res.code != 200) {
  360. return uni.showToast({
  361. title: res.data.msg,
  362. icon: "none"
  363. });
  364. } else {
  365. uni.showToast({
  366. title: "发送成功",
  367. icon: "none"
  368. });
  369. }
  370. // 发送成功,开启倒计时
  371. this.codetime = 60;
  372. let timer = setInterval(() => {
  373. this.codetime--;
  374. if (this.codetime < 1) {
  375. clearInterval(timer);
  376. this.codetime = 0;
  377. }
  378. }, 1000);
  379. },
  380. //#ifdef APP-PLUS
  381. quxiao() {
  382. this.show = false;
  383. this.$login({
  384. url: "/login2",
  385. data: {
  386. account: this.username,
  387. password: this.password,
  388. captcha: this.imgcode.toLowerCase(),
  389. captchaId: this.captchaId,
  390. }
  391. }).then(res => {
  392. if (res) {
  393. return uni.showToast({
  394. title: res.msg,
  395. icon: 'none'
  396. });
  397. } else {}
  398. })
  399. },
  400. queren() {
  401. this.show = false;
  402. this.$login({
  403. url: "/login2",
  404. data: {
  405. account: this.username,
  406. password: this.password,
  407. captcha: this.imgcode.toLowerCase(),
  408. captchaId: this.captchaId,
  409. }
  410. }).then(async res => {
  411. if (res) {
  412. return uni.showToast({
  413. title: res.msg,
  414. icon: 'none'
  415. });
  416. } else {
  417. this.deleteTableData();
  418. this.openSQL();
  419. this.createTable(); //创建表
  420. this.insertTableData(this.username, this.password); //新增表数据
  421. }
  422. })
  423. },
  424. //#endif
  425. // 提交登录
  426. submit() {
  427. if (!this.checked) {
  428. return this.$refs.uToast.show({
  429. title: '请阅读后勾选并同意《用户协议》及《隐私政策》',
  430. type: 'default',
  431. })
  432. }
  433. // // 账号密码登录
  434. uni.hideKeyboard();
  435. if (this.current == 0) {
  436. //#ifdef H5
  437. this.$login({
  438. url: "/login2",
  439. data: {
  440. account: this.username,
  441. password: this.password,
  442. captcha: this.imgcode.toLowerCase(),
  443. captchaId: this.captchaId,
  444. }
  445. }).then(res => {
  446. if (res) {
  447. return uni.showToast({
  448. title: res.msg,
  449. icon: 'none'
  450. });
  451. } else {}
  452. })
  453. // }
  454. //#endif
  455. //#ifdef APP-PLUS
  456. if (this.listData.length > 0) {
  457. this.listData.map(ele => {
  458. if (this.username == ele.username && this.password == ele.password) {
  459. this.$login({
  460. url: "/login2",
  461. data: {
  462. account: this.username,
  463. password: this.password,
  464. captcha: this.imgcode.toLowerCase(),
  465. captchaId: this.captchaId,
  466. }
  467. }).then(res => {
  468. if (res) {
  469. return uni.showToast({
  470. title: res.msg,
  471. icon: 'none'
  472. });
  473. } else {}
  474. })
  475. } else {
  476. this.show = true;
  477. }
  478. })
  479. } else {
  480. this.$login({
  481. url: "/login2",
  482. data: {
  483. account: this.username,
  484. password: this.password,
  485. captcha: this.imgcode.toLowerCase(),
  486. captchaId: this.captchaId,
  487. }
  488. }).then(res => {
  489. if (res) {
  490. return uni.showToast({
  491. title: res.msg,
  492. icon: 'none'
  493. });
  494. } else {
  495. this.openSQL(); //打开数据库
  496. this.createTable(); //创建表
  497. this.insertTableData(this.username, this.password); //新增表数据
  498. }
  499. })
  500. }
  501. //#endif
  502. } else {
  503. // 验证码登录
  504. // 验证手机号合法性
  505. if (!this.$base.phoneRegular.test(this.phone)) {
  506. return uni.showToast({
  507. title: '请输入正确的手机号码',
  508. icon: 'none'
  509. });
  510. }
  511. this.$login({
  512. url: "/loginByPhone",
  513. data: {
  514. phone: this.phone,
  515. phoneMsg: this.checknum
  516. }
  517. }).then(res => {
  518. if (res) {
  519. return uni.showToast({
  520. title: res.msg,
  521. icon: 'none'
  522. });
  523. }
  524. return;
  525. })
  526. }
  527. },
  528. // 微信APP登录
  529. onWxAppLogin() {
  530. this.loginMethod = 'onWxAppLogin';
  531. var that = this;
  532. if (!this.checked) {
  533. this.privacyPolicyValidation = true;
  534. } else {
  535. uni.login({
  536. provider: 'weixin',
  537. onlyAuthorize: true,
  538. success: function(loginRes) {
  539. that.codeRes(loginRes.code);
  540. },
  541. fail: (err) => {
  542. uni.showToast({
  543. title: '绑定失败',
  544. icon: "none"
  545. });
  546. }
  547. });
  548. }
  549. },
  550. onzfbAppLogin() {
  551. this.loginMethod = 'onzfbAppLogin';
  552. if (!this.checked) {
  553. this.privacyPolicyValidation = true;
  554. } else {
  555. let urls =
  556. 'https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021004153668213&scope=auth_user&redirect_uri=https://test.baoxianzhanggui.com/pay/';
  557. urls = encodeURIComponent(urls); //将地址编码成浏览器访问的格式
  558. plus.runtime.openURL(
  559. 'alipays://platformapi/startapp?appId=20000067&url=' + urls,
  560. res => {
  561. //这里写打开URL地址失败后的处理0
  562. uni.showModal({
  563. content: '本机未检测到对应客户端,是否打开浏览器访问页面?',
  564. success: function(res) {
  565. if (res.confirm) {
  566. //plus.runtime.openURL();
  567. }
  568. }
  569. });
  570. },
  571. 'com.eg.android.AlipayGphone'
  572. );
  573. }
  574. },
  575. codeRes(code) {
  576. this.$login({
  577. url: "/wechat/login",
  578. data: {
  579. code: code,
  580. }
  581. }).then(res => {
  582. return uni.showToast({
  583. title: res.msg,
  584. icon: 'none'
  585. });
  586. return;
  587. })
  588. },
  589. // 打开数据库
  590. openSQL() {
  591. // 这个是查询有没有打开数据库
  592. let open = DB.isOpen();
  593. DB.openSqlite()
  594. .then(res => {})
  595. .catch(error => {});
  596. },
  597. // 关闭数据库
  598. closeSQL() {
  599. // 这个是查询有没有打开数据库
  600. let open = DB.isOpen();
  601. if (open) {
  602. DB.closeSqlite()
  603. .then(res => {
  604. // this.showToast("数据库已关闭");
  605. })
  606. .catch(error => {
  607. // this.showToast("数据库关闭失败");
  608. });
  609. }
  610. },
  611. // 创建表
  612. createTable() {
  613. let open = DB.isOpen();
  614. if (open) {
  615. this.openSQL();
  616. let sql =
  617. '"id" INTEGER PRIMARY KEY AUTOINCREMENT,"username" text,"password" text,"time" text';
  618. // 创建表 DB.createTable(表名, 表的列)
  619. DB.createTable("chat", sql)
  620. .then(res => {
  621. // this.showToast("创建chat表成功");
  622. })
  623. .catch(error => {});
  624. } else {}
  625. },
  626. // 新增表数据
  627. insertTableData(user, word) {
  628. let open = DB.isOpen();
  629. if (open) {
  630. let arr = [{
  631. username: user,
  632. password: word,
  633. }]
  634. arr.map(item => {
  635. let time = this.formatDate(new Date().getTime());
  636. let sql =
  637. `'${item.username}','${item.password}','${time}'`;
  638. let condition = "'username','password','time'";
  639. // 新增 DB.insertTableData(表名, 对应表头列的数据)
  640. DB.insertTableData("chat", sql, condition)
  641. .then(res => {
  642. this.selectTableData();
  643. })
  644. .catch(error => {});
  645. })
  646. } else {}
  647. },
  648. // 查询表数据
  649. selectTableData() {
  650. let open = DB.isOpen();
  651. if (open) {
  652. // 查询表 DB.selectTableData(表名,查询条件列名,查询条件列值)
  653. DB.selectTableData("chat")
  654. .then(res => {
  655. this.listData = res;
  656. this.username = res[0].username;
  657. this.password = res[0].password;
  658. })
  659. .catch(error => {});
  660. } else {}
  661. },
  662. // 修改表数据
  663. updateTableData() {
  664. let open = DB.isOpen();
  665. if (open) {
  666. let time = this.formatDate(new Date().getTime());
  667. let data =
  668. `username ='${this.username}',password ='${this.password}'`;
  669. // 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
  670. DB.updateTableData("chat", data)
  671. .then(res => {
  672. this.showToast("保存成功");
  673. this.selectTableData();
  674. })
  675. .catch(error => {});
  676. } else {}
  677. },
  678. // 删除表
  679. deleteTableData() {
  680. let open = DB.isOpen();
  681. if (open) {
  682. // 删除表 DB.deleteTableData(表名,查询条件列名,查询条件列值)
  683. DB.dropTable("chat")
  684. .then(res => {})
  685. .catch(error => {});
  686. } else {}
  687. },
  688. // 提示框
  689. showToast: function(str) {
  690. uni.showToast({
  691. icon: "none",
  692. title: str,
  693. mask: true
  694. });
  695. },
  696. // 时间戳转年月日
  697. formatDate(data) {
  698. let now = new Date(data);
  699. var year = now.getFullYear(); //取得4位数的年份
  700. var month =
  701. now.getMonth() + 1 < 10 ?
  702. "0" + (now.getMonth() + 1) :
  703. now.getMonth() + 1;
  704. var date = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();
  705. var hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
  706. var minute =
  707. now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
  708. var second =
  709. now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
  710. return (
  711. year +
  712. "-" +
  713. month +
  714. "-" +
  715. date +
  716. " " +
  717. hour +
  718. ":" +
  719. minute +
  720. ":" +
  721. second
  722. );
  723. }
  724. },
  725. //页面隐藏
  726. onHide() {},
  727. //页面卸载
  728. onUnload() {},
  729. //页面下来刷新
  730. onPullDownRefresh() {},
  731. //页面上拉触底
  732. onReachBottom() {},
  733. };
  734. </script>
  735. <style lang="scss" scoped>
  736. /deep/ {
  737. .u-tab-bar {
  738. background: linear-gradient(90deg, #0052FF 0%, rgba(0, 82, 255, 0) 100%) !important;
  739. border-radius: 4px 4px 4px 4px;
  740. }
  741. }
  742. .privacyPolicyValidationclass {
  743. padding: 20px;
  744. .title {
  745. font-weight: bold;
  746. font-size: 14px;
  747. margin-bottom: 10px;
  748. }
  749. .content {
  750. font-size: 13px;
  751. color: #333;
  752. margin-bottom: 20px;
  753. }
  754. }
  755. .shu1 {
  756. display: flex;
  757. flex-direction: column;
  758. justify-content: space-between;
  759. align-items: center;
  760. }
  761. .shili_btn {
  762. width: 100%;
  763. height: 90rpx;
  764. border-top: 2rpx solid #F2F2F2;
  765. }
  766. .shili_btn>view {
  767. width: 50%;
  768. height: 100%;
  769. background-color: #ffffff;
  770. cursor: pointer;
  771. }
  772. .shili_btn>view:nth-child(2) {
  773. color: #FFFFFF;
  774. background-color: #007BFF;
  775. }
  776. .shili>text:nth-child(1) {
  777. font-weight: bold;
  778. }
  779. .shili {
  780. padding: 40rpx;
  781. box-sizing: border-box;
  782. }
  783. .heng {
  784. display: flex;
  785. justify-content: space-between;
  786. align-items: center;
  787. }
  788. .heng1 {
  789. display: flex;
  790. justify-content: center;
  791. align-items: center;
  792. }
  793. /* 第三方登录Start */
  794. .third_party_login_box {
  795. position: fixed;
  796. bottom: 50rpx;
  797. left: 0;
  798. right: 0;
  799. height: 80px;
  800. padding: 0 30rpx;
  801. }
  802. .third_party_login_box .third_party_title {
  803. display: flex;
  804. align-items: center;
  805. }
  806. .third_party_login_box .third_party_title:before,
  807. .third_party_login_box .third_party_title:after {
  808. content: "";
  809. flex: 1;
  810. height: 2rpx;
  811. background-color: #f5f5f5;
  812. }
  813. .third_party_login_box .third_party_title text {
  814. font-size: 24rpx;
  815. color: #999999;
  816. flex-shrink: 0;
  817. padding: 0 20rpx;
  818. }
  819. .third_party_login_box .third_party_content {
  820. height: 55px;
  821. display: flex;
  822. justify-content: center;
  823. align-items: center;
  824. }
  825. .third_party_login_box .third_party_content image {
  826. margin: 0rpx 20rpx;
  827. width: 80rpx;
  828. height: 80rpx;
  829. }
  830. /* 第三方登录End */
  831. .yanzhengmaView1 {
  832. background: #FFFFFF;
  833. border-radius: 10rpx;
  834. width: 150rpx;
  835. padding: 5rpx 0;
  836. }
  837. .yanzhengmaView2 {
  838. background: #FFFFFF;
  839. border-radius: 10rpx;
  840. width: 220rpx;
  841. padding: 5rpx 0;
  842. }
  843. .bg-color {
  844. background-color: #0052FF;
  845. border-radius: 20px;
  846. }
  847. .bg-hover-color {
  848. background-color: #0052FF;
  849. opacity: 0.65;
  850. border-radius: 20px;
  851. }
  852. .text-color {
  853. color: #0052FF;
  854. }
  855. </style>