login.vue 23 KB

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