login.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878
  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: "/aapLogin",
  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: "/aapLogin",
  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: "/aapLogin",
  484. data: {
  485. account: this.username,
  486. password: this.password,
  487. captcha: this.imgcode.toLowerCase(),
  488. captchaId: this.captchaId,
  489. }
  490. }).then(res => {
  491. if (res) {
  492. return uni.showToast({
  493. title: res.msg,
  494. icon: 'none'
  495. });
  496. } else {
  497. this.openSQL(); //打开数据库
  498. this.createTable(); //创建表
  499. this.insertTableData(this.username, this.password); //新增表数据
  500. socket.init();
  501. }
  502. })
  503. }
  504. //#endif
  505. } else {
  506. // 验证码登录
  507. // 验证手机号合法性
  508. if (!this.$base.phoneRegular.test(this.phone)) {
  509. return uni.showToast({
  510. title: '请输入正确的手机号码',
  511. icon: 'none'
  512. });
  513. }
  514. this.$login({
  515. url: "/loginAPPByPhone",
  516. data: {
  517. phone: this.phone,
  518. phoneMsg: this.checknum
  519. }
  520. }).then(res => {
  521. if (res) {
  522. return uni.showToast({
  523. title: res.msg,
  524. icon: 'none'
  525. });
  526. }
  527. // socket.init();
  528. return;
  529. })
  530. }
  531. },
  532. // 微信APP登录
  533. onWxAppLogin() {
  534. var that = this;
  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. console.log('login fail:', err);
  547. }
  548. });
  549. },
  550. onzfbAppLogin() {
  551. let urls =
  552. 'https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021004193614682&scope=auth_user&redirect_uri=https://test.baoxianzhanggui.com/partnerPay/';
  553. urls = encodeURIComponent(urls); //将地址编码成浏览器访问的格式
  554. plus.runtime.openURL(
  555. 'alipays://platformapi/startapp?appId=20000067&url=' + urls,
  556. res => {
  557. //这里写打开URL地址失败后的处理0
  558. uni.showModal({
  559. content: '本机未检测到对应客户端,是否打开浏览器访问页面?',
  560. success: function(res) {
  561. if (res.confirm) {
  562. //plus.runtime.openURL();
  563. }
  564. }
  565. });
  566. },
  567. 'com.eg.android.AlipayGphone'
  568. );
  569. },
  570. codeRes(code) {
  571. this.$login({
  572. url: "/APPPartner/loginWechat",
  573. data: {
  574. code: code,
  575. }
  576. }).then(res => {
  577. return uni.showToast({
  578. title: res.msg,
  579. icon: 'none'
  580. });
  581. return;
  582. })
  583. },
  584. // 打开数据库
  585. openSQL() {
  586. // 这个是查询有没有打开数据库
  587. let open = DB.isOpen();
  588. DB.openSqlite()
  589. .then(res => {})
  590. .catch(error => {});
  591. },
  592. // 关闭数据库
  593. closeSQL() {
  594. // 这个是查询有没有打开数据库
  595. let open = DB.isOpen();
  596. if (open) {
  597. DB.closeSqlite()
  598. .then(res => {
  599. // this.showToast("数据库已关闭");
  600. })
  601. .catch(error => {
  602. // this.showToast("数据库关闭失败");
  603. });
  604. }
  605. },
  606. // 创建表
  607. createTable() {
  608. let open = DB.isOpen();
  609. if (open) {
  610. this.openSQL();
  611. let sql =
  612. '"id" INTEGER PRIMARY KEY AUTOINCREMENT,"username" text,"password" text,"time" text';
  613. // 创建表 DB.createTable(表名, 表的列)
  614. DB.createTable("chat", sql)
  615. .then(res => {
  616. // this.showToast("创建chat表成功");
  617. })
  618. .catch(error => {});
  619. } else {}
  620. },
  621. // 新增表数据
  622. insertTableData(user, word) {
  623. let open = DB.isOpen();
  624. if (open) {
  625. let arr = [{
  626. username: user,
  627. password: word,
  628. }]
  629. arr.map(item => {
  630. let time = this.formatDate(new Date().getTime());
  631. let sql =
  632. `'${item.username}','${item.password}','${time}'`;
  633. let condition = "'username','password','time'";
  634. // 新增 DB.insertTableData(表名, 对应表头列的数据)
  635. DB.insertTableData("chat", sql, condition)
  636. .then(res => {
  637. this.selectTableData();
  638. })
  639. .catch(error => {});
  640. })
  641. } else {}
  642. },
  643. // 查询表数据
  644. selectTableData() {
  645. let open = DB.isOpen();
  646. if (open) {
  647. // 查询表 DB.selectTableData(表名,查询条件列名,查询条件列值)
  648. DB.selectTableData("chat")
  649. .then(res => {
  650. console.log("contact表数据", res);
  651. this.listData = res;
  652. this.username = res[0].username;
  653. this.password = res[0].password;
  654. })
  655. .catch(error => {});
  656. } else {}
  657. },
  658. // 修改表数据
  659. updateTableData() {
  660. let open = DB.isOpen();
  661. if (open) {
  662. let time = this.formatDate(new Date().getTime());
  663. let data =
  664. `username ='${this.username}',password ='${this.password}'`;
  665. // 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
  666. DB.updateTableData("chat", data)
  667. .then(res => {
  668. console.log('修改后的数据', res)
  669. this.showToast("保存成功");
  670. this.selectTableData();
  671. })
  672. .catch(error => {
  673. console.log(error)
  674. });
  675. } else {}
  676. },
  677. // 删除表
  678. deleteTableData() {
  679. let open = DB.isOpen();
  680. if (open) {
  681. // 删除表 DB.deleteTableData(表名,查询条件列名,查询条件列值)
  682. DB.dropTable("chat")
  683. .then(res => {})
  684. .catch(error => {});
  685. } else {}
  686. },
  687. // 提示框
  688. showToast: function(str) {
  689. uni.showToast({
  690. icon: "none",
  691. title: str,
  692. mask: true
  693. });
  694. },
  695. // 时间戳转年月日
  696. formatDate(data) {
  697. let now = new Date(data);
  698. var year = now.getFullYear(); //取得4位数的年份
  699. var month =
  700. now.getMonth() + 1 < 10 ?
  701. "0" + (now.getMonth() + 1) :
  702. now.getMonth() + 1;
  703. var date = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();
  704. var hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
  705. var minute =
  706. now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
  707. var second =
  708. now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
  709. return (
  710. year +
  711. "-" +
  712. month +
  713. "-" +
  714. date +
  715. " " +
  716. hour +
  717. ":" +
  718. minute +
  719. ":" +
  720. second
  721. );
  722. }
  723. },
  724. //页面隐藏
  725. onHide() {},
  726. //页面卸载
  727. onUnload() {},
  728. //页面下来刷新
  729. onPullDownRefresh() {},
  730. //页面上拉触底
  731. onReachBottom() {},
  732. };
  733. </script>
  734. <style lang="scss" scoped>
  735. ::v-deep {
  736. .u-tab-bar {
  737. background: linear-gradient(90deg, #FF9E2D 0%, rgba(0, 82, 255, 0) 100%) !important;
  738. border-radius: 4px 4px 4px 4px;
  739. }
  740. }
  741. .shu1 {
  742. display: flex;
  743. flex-direction: column;
  744. justify-content: space-between;
  745. align-items: center;
  746. }
  747. .shili_btn {
  748. width: 100%;
  749. height: 90rpx;
  750. border-top: 2rpx solid #F2F2F2;
  751. }
  752. .shili_btn>view {
  753. width: 50%;
  754. height: 100%;
  755. background-color: #ffffff;
  756. cursor: pointer;
  757. }
  758. .shili_btn>view:nth-child(2) {
  759. color: #FFFFFF;
  760. background-color: #FF9E2D;
  761. }
  762. .shili>text:nth-child(1) {
  763. font-weight: bold;
  764. }
  765. .shili {
  766. padding: 40rpx;
  767. box-sizing: border-box;
  768. }
  769. .heng {
  770. display: flex;
  771. justify-content: space-between;
  772. align-items: center;
  773. }
  774. .heng1 {
  775. display: flex;
  776. justify-content: center;
  777. align-items: center;
  778. }
  779. /* 第三方登录Start */
  780. .third_party_login_box {
  781. position: fixed;
  782. bottom: 50rpx;
  783. left: 0;
  784. right: 0;
  785. height: 170rpx;
  786. padding: 0 30rpx;
  787. }
  788. .third_party_login_box .third_party_title {
  789. display: flex;
  790. align-items: center;
  791. }
  792. .third_party_login_box .third_party_title:before,
  793. .third_party_login_box .third_party_title:after {
  794. content: "";
  795. flex: 1;
  796. height: 2rpx;
  797. background-color: #f5f5f5;
  798. }
  799. .third_party_login_box .third_party_title text {
  800. font-size: 24rpx;
  801. color: #999999;
  802. flex-shrink: 0;
  803. padding: 0 20rpx;
  804. }
  805. .third_party_login_box .third_party_content {
  806. height: 140rpx;
  807. display: flex;
  808. justify-content: center;
  809. align-items: center;
  810. }
  811. .third_party_login_box .third_party_content image {
  812. margin: 0rpx 20rpx;
  813. width: 80rpx;
  814. height: 80rpx;
  815. }
  816. /* 第三方登录End */
  817. .yanzhengmaView1 {
  818. background: #FFFFFF;
  819. border-radius: 10rpx;
  820. width: 150rpx;
  821. padding: 5rpx 0;
  822. }
  823. .yanzhengmaView2 {
  824. background: #FFFFFF;
  825. border-radius: 10rpx;
  826. width: 220rpx;
  827. padding: 5rpx 0;
  828. }
  829. .bg-color {
  830. background-color: #FF9E2D;
  831. border-radius: 20px;
  832. }
  833. .bg-hover-color {
  834. background-color: #FF9E2D !important;
  835. opacity: 0.65;
  836. border-radius: 20px;
  837. }
  838. .text-color {
  839. color: #FF9E2D;
  840. }
  841. </style>