LoginView.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <view class="">
  3. <customNav :shownav="true" :title="$t('index.dengluzhuce')" titledetl=""></customNav>
  4. <view class="contentV">
  5. <!-- <text class="titlev">{{$t('index.huanying')}}</text> -->
  6. <view style="margin-top: 120rpx;">
  7. <!-- <view class="contentInRowS duoyuyanctv" @click="duoyuyan">
  8. <view class="contentInRowL">
  9. <image class="duoyuyIcon" src="/static/images/yuyan@3x.png" mode="scaleToFill"></image>
  10. <text>Ngôn ngữ/语言</text>
  11. </view>
  12. <image style="width: 30rpx;" src="/static/images/fanhui@3x.png" mode="widthFix"></image>
  13. </view> -->
  14. </view>
  15. <view class="yzmctV">
  16. <view class="xialakuangct" @click="popgjm">
  17. <text>{{guojiadaima}}</text>
  18. <image style="width: 36rpx;height: 36rpx;padding-right: 16rpx;" src="/static/images/xiala@3x.png" mode="scaleToFill"></image>
  19. </view>
  20. <input class="noinputV" type="number" :placeholder="$t('index.shoujihao')" @input="phoneinput">
  21. </view>
  22. <view class="yzmctV noinputVcode">
  23. <input class="yzminputV" type="text" :placeholder="$t('index.yanzhengma')" @input="smsCodeinput">
  24. <text class="yzmbt" @click="getSMScode">{{smsCodeNote}}</text>
  25. </view>
  26. <view class="yzmctV">
  27. <text class="querenBt" @click="loginAC">{{$t('index.dengluzhuce')}}</text>
  28. </view>
  29. <view class="contentInRowC" style="margin-top: 40rpx;" @click="yueduyszc">
  30. <text class="linktext">{{$t('index.yuedu')}}{{$t('index.yinsizc')}}</text>
  31. </view>
  32. </view>
  33. <popViewGG :tips="$t('index.gjqhxz')" :show="showpop" :maskClosable="true" :isCancel="true" @chooseCancel="chooseCancel">
  34. <picker-view :indicator-style="indicatorStyle" :value="pvalue" @change="bindChange" class="picker-view">
  35. <picker-view-column>
  36. <view class="item" v-for="(item,index) in range" :key="index">{{item}}</view>
  37. </picker-view-column>
  38. </picker-view>
  39. </popViewGG>
  40. </view>
  41. </template>
  42. <script>
  43. import api from "@/pages/api/api.js";
  44. export default {
  45. data() {
  46. return {
  47. pvalue: [0],
  48. indicatorStyle: `height: 50px;`,
  49. range: ["+886","+86"],
  50. showpop:false,
  51. phone:'',
  52. smsCode:'',
  53. smsCodeNote:'',
  54. timer:'',
  55. timeCall:0,
  56. guojiadaima:'+886',
  57. cid:''
  58. }
  59. },
  60. onShow() {
  61. var that=this;
  62. this.smsCodeNote=this.$t('index.huoquyzm');
  63. uni.getPushClientId({
  64. success: (res) => {
  65. that.cid = res.cid;
  66. console.log('客户端推送标识:',that.cid)
  67. uni.setStorageSync("cid",that.cid);
  68. },
  69. fail(err) {
  70. // uni.showToast({
  71. // title:'获取推送标识失败',
  72. // icon: 'none',
  73. // duration: 4000
  74. // })
  75. console.log(err)
  76. }
  77. });
  78. //this.UpdataToken();
  79. },
  80. methods: {
  81. bindChange (e) {
  82. var val = e.detail.value[0];
  83. this.guojiadaima=this.range[val];
  84. },
  85. popgjm(){
  86. this.showpop=true;
  87. },
  88. chooseCancel(){
  89. this.showpop=false;
  90. },
  91. duoyuyan(){
  92. uni.navigateTo({
  93. url:'/pages/UserCenter/yonghushezhi/duoyuyan'
  94. })
  95. },
  96. phoneinput(event){
  97. this.phone = event.target.value;
  98. },
  99. smsCodeinput(event){
  100. this.smsCode = event.target.value;
  101. },
  102. yueduyszc(){
  103. uni.navigateTo({
  104. url:'/pages/index/mindex/yinszhengc'
  105. })
  106. },
  107. getSMScode(){
  108. if(this.phone.length<=0){
  109. uni.showToast({
  110. title: this.$t('index.shoujihao'),
  111. icon: 'none',
  112. duration: 3500
  113. })
  114. return;
  115. }
  116. var top = this.phone.substring(0,1);
  117. if(top=='0'){
  118. this.phone=this.phone.slice(1);
  119. }
  120. console.log(this.phone)
  121. if(this.timeCall==0){
  122. this.getSMScodeact();
  123. this.timeCall=60;
  124. }
  125. else{
  126. return;
  127. }
  128. var that = this;
  129. this.timer = setInterval(() => {
  130. that.timeCall=that.timeCall-1;
  131. if(that.timeCall==0){
  132. clearInterval(that.timer);
  133. that.smsCodeNote = that.$t('index.huoquyzm');
  134. }
  135. else{
  136. that.smsCodeNote = that.$t('index.chongxhq')+'('+that.timeCall+')';
  137. }
  138. }, 1000);
  139. },
  140. getSMScodeact(){
  141. console.log("getSMScodeact");
  142. api('smsCode',{
  143. phone:this.guojiadaima+this.phone
  144. },res=>{
  145. uni.showToast({
  146. title:res.data.msg,
  147. icon: 'none',
  148. duration: 1500
  149. })
  150. },failc=>{
  151. //console.log('getadvertis----',failc)
  152. })
  153. },
  154. loginAC(){
  155. if(this.phone.length<=0){
  156. uni.showToast({
  157. title: this.$t('index.shoujihao'),
  158. icon: 'none',
  159. duration: 3500
  160. })
  161. return;
  162. }
  163. var top = this.phone.substring(0,1);
  164. if(top=='0'){
  165. this.phone=this.phone.slice(1);
  166. }
  167. if(this.smsCode.length<=0){
  168. uni.showToast({
  169. title: this.$t('index.yanzhengma'),
  170. icon: 'none',
  171. duration: 3500
  172. })
  173. return;
  174. }
  175. this.loginUp();
  176. },
  177. loginUp(){
  178. console.log(this.guojiadaima+this.phone,this.smsCode,this.cid)
  179. api('loginBySmsCode',{
  180. phone:this.guojiadaima+this.phone,
  181. code:this.smsCode,
  182. cid:this.cid
  183. },res=>{
  184. console.log(res)
  185. if(res.data.code==200){
  186. plus.nativeUI.toast(this.$t('api.dengluchengg'), {
  187. icon : "none",// eg. "/img/add.png"
  188. duration : "long",// 持续3.5s,short---2s
  189. align : "center",// 水平居中
  190. verticalAlign : "bottom"// 垂直底部
  191. });
  192. getApp().globalData.token = res.data.token;
  193. uni.setStorageSync("token",res.data.token);
  194. uni.setStorageSync("userId",res.data.data.userId);
  195. uni.setStorageSync('userInfo',res.data.data);
  196. getApp().globalData.initgoEasy();
  197. uni.navigateBack();
  198. return;
  199. }
  200. if(res.data.code==500){
  201. uni.showToast({
  202. title: res.data.msg,
  203. icon: 'none',
  204. duration: 3500
  205. })
  206. return;
  207. }
  208. uni.showToast({
  209. title: this.$t('api.denglusb'),
  210. icon: 'none',
  211. duration: 3500
  212. })
  213. },failc=>{
  214. uni.showToast({
  215. title: this.$t('api.denglushibai'),
  216. icon: 'none',
  217. duration: 2500
  218. })
  219. })
  220. },
  221. }
  222. }
  223. </script>
  224. <style>
  225. page{
  226. background-color:white;
  227. }
  228. .topimag{
  229. width: 100%;
  230. }
  231. .contentV{
  232. display: flex;
  233. width: 92%;
  234. margin-left: 4%;
  235. flex-direction: column;
  236. justify-content: flex-start;
  237. }
  238. .titlev{
  239. width: 100%;
  240. height: 60rpx;
  241. line-height: 60rpx;
  242. font-size: 36rpx;
  243. font-weight: bold;
  244. text-align: left;
  245. }
  246. .yzmctV{
  247. display: flex;
  248. flex-direction: row;
  249. align-items: center;
  250. justify-content:flex-start;
  251. margin-top: 30rpx;
  252. width: 100%;
  253. }
  254. .noinputV{
  255. width: 73%;
  256. height: 80rpx;
  257. line-height: 80rpx;
  258. border-radius: 10rpx;
  259. border: 2rpx solid #F2F3F7;
  260. background-color: #F2F3F7;
  261. }
  262. .yzminputV{
  263. width: 73%;
  264. }
  265. .noinputVcode{
  266. width: 99%;
  267. height: 80rpx;
  268. line-height: 80rpx;
  269. border-radius: 10rpx;
  270. border: 2rpx solid #F2F3F7;
  271. background-color: #F2F3F7;
  272. }
  273. .yzmbt{
  274. color: white;
  275. font-size: 26rpx;
  276. width: 170rpx;
  277. height: 60rpx;
  278. line-height: 60rpx;
  279. text-align: center;
  280. margin-left: auto;
  281. margin-right: 10rpx;
  282. border-radius: 2rpx;
  283. background-color:#60BA63;
  284. }
  285. .querenBt{
  286. margin-top: 30rpx;
  287. width: 100%;
  288. height: 60rpx;
  289. line-height: 60rpx;
  290. padding: 10rpx;
  291. border-radius: 20rpx;
  292. border: solid #40AE36;
  293. border-width: 0px 0px 6rpx 0px;
  294. text-align: center;
  295. justify-content: center;
  296. background-color: #40AE36;
  297. color: white;
  298. box-shadow: 0rpx 0rpx 10rpx 0rpx #40AE36;
  299. }
  300. .linktext{
  301. font-size: 24rpx;
  302. color:skyblue;
  303. text-decoration:underline;
  304. }
  305. .notetext{
  306. color: darkgray;
  307. font-size: 24rpx;
  308. text-align: center;
  309. }
  310. .xialakuangct{
  311. display: flex;
  312. flex-direction: row;
  313. align-items: center;
  314. justify-content:space-between;
  315. padding-left: 16rpx;
  316. margin-right: 20rpx;
  317. width: 140rpx;
  318. height: 80rpx;
  319. line-height: 80rpx;
  320. border-radius: 10rpx;
  321. border: 2rpx solid #F2F3F7;
  322. background-color: #F2F3F7;
  323. }
  324. .xialakuang{
  325. width: 100%;
  326. }
  327. .lineview{
  328. display: flex;
  329. flex-direction: row;
  330. align-items: center;
  331. justify-content: center;
  332. background-color: whitesmoke;
  333. border: solid darkgray;
  334. border-width: 0px 0px 1rpx 0px;
  335. width: 80%;
  336. margin-bottom: 12rpx;
  337. }
  338. .picker-view {
  339. width: 750rpx;
  340. height: 300rpx;
  341. margin-top: 10rpx;
  342. }
  343. .item {
  344. line-height: 100rpx;
  345. text-align: center;
  346. }
  347. .duoyuyanctv{
  348. margin-top: 20rpx;
  349. padding: 30rpx;
  350. border: solid lavender;
  351. border-width: 0px 0px 1rpx 0px;
  352. }
  353. .duoyuyIcon{
  354. width: 40rpx;
  355. height: 40rpx;
  356. }
  357. </style>