bindMobile.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view>
  3. <view class="content">
  4. <image class="backImg" @tap="goBack()" src="../../static/images/icon_close.png"></image>
  5. <view class="pageTop">
  6. <view class="head x-c"> 绑定手机号</view>
  7. <view class="loginBox">
  8. <view class="login-item">
  9. <view class="input-account">
  10. <input v-model="userName" placeholder="请输入手机号" type="number" />
  11. </view>
  12. <view class="line"></view>
  13. </view>
  14. <view class="login-item">
  15. <view class="input-pwd">
  16. <input v-model="password" placeholder="请输入密码" type="password" />
  17. </view>
  18. <view class="line"></view>
  19. </view>
  20. <view class="btns">
  21. <view class="login-btn" @click="bindAccount">立即绑定</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { login,loginByWeChat,loginByApple,setPhone,setIPhoneNumber } from '@/api/user'
  30. export default {
  31. data() {
  32. return {
  33. userName:"",
  34. password:"",
  35. registrationID:"",
  36. unionid:"",
  37. userPhone:"",
  38. loginType:0,
  39. isApp:false,
  40. isAgreePrivacy:false,
  41. isIos:false,
  42. from: '',
  43. source:'',
  44. appleKey:""
  45. }
  46. },
  47. onLoad(option) {
  48. // #ifdef APP-PLUS
  49. this.isIos = plus.os.name == "iOS"
  50. this.isApp=true;
  51. this.source = plus.runtime.channel || 'app'
  52. if(this.isIos){
  53. this.source="iOS";
  54. }
  55. // #endif
  56. this.from= option.from || ''
  57. let that=this;
  58. uni.$on('getRegistrationID', function(data) {
  59. that.registrationID=data;
  60. });
  61. this.appleKey=option.appleKey;
  62. },
  63. onShow() {
  64. },
  65. onUnload() {
  66. uni.$off('getRegistrationID');
  67. },
  68. mounted() {
  69. },
  70. methods: {
  71. bindAccount(){
  72. if (this.$isEmpty(this.userName)) {
  73. uni.showToast({
  74. title: "请输入手机号",
  75. icon: 'none',
  76. });
  77. return;
  78. }
  79. if (this.$isEmpty(this.password)) {
  80. uni.showToast({
  81. title: "请输入密码",
  82. icon: 'none',
  83. });
  84. return;
  85. }
  86. uni.showLoading({
  87. title:"处理中..."
  88. });
  89. this.setPhoneNumberAct(3,this.unionid);
  90. },
  91. setPhoneNumberAct(type,unionId){
  92. let params={
  93. phone:this.userName,
  94. password:this.password,
  95. appleKey:this.appleKey,
  96. unionId:unionId,
  97. source:this.source,
  98. simExist:0
  99. };
  100. setIPhoneNumber(params).then(res => {
  101. console.log("setIPhoneNumber res:",res);
  102. uni.hideLoading();
  103. if(res.code==200){
  104. uni.setStorageSync('AppToken',res.token);
  105. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  106. uni.$emit('refreshIM');
  107. this.goPage()
  108. }
  109. else{
  110. uni.showToast({title: res.msg,icon: 'none'});
  111. }
  112. },
  113. rej => {}
  114. );
  115. },
  116. setPhoneAct(type,phone,unionId){
  117. let params={
  118. phone:phone,
  119. unionId:unionId,
  120. source:this.source,
  121. };
  122. if(type==3) {
  123. params={
  124. phone:phone,
  125. unionId:unionId,
  126. appleKey: this.appleKey,
  127. source:this.source
  128. };
  129. }
  130. setPhone(params).then(res => {
  131. uni.hideLoading();
  132. if(res.code==200){
  133. uni.setStorageSync('AppToken',res.token);
  134. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  135. uni.closeAuthView();
  136. uni.$emit('refreshIM');
  137. this.goPage()
  138. }
  139. else{
  140. uni.showToast({title: res.msg,icon: 'none'});
  141. uni.closeAuthView();
  142. }
  143. },
  144. rej => {}
  145. );
  146. },
  147. getRegistrationID(){
  148. this.registrationID=uni.getStorageSync("registrationID");
  149. if(this.registrationID==null || this.registrationID==""){
  150. uni.getPushClientId({success: res => {
  151. uni.setStorageSync("registrationID",res.cid);
  152. this.registrationID = res.cid
  153. }
  154. });
  155. }
  156. },
  157. goBack(){
  158. uni.$emit('showHealthButler');
  159. // this.$navBack();
  160. uni.redirectTo({
  161. url: "/pages/auth/loginIndex"
  162. });
  163. },
  164. goPage() {
  165. let pages = getCurrentPages();
  166. let url = pages[ pages.length - 1];
  167. let openUrl = uni.getStorageSync("openUrl");
  168. if(openUrl) {
  169. uni.navigateTo({
  170. url: openUrl,
  171. success: function(res) {
  172. uni.removeStorageSync("openUrl")
  173. }
  174. })
  175. }
  176. else {
  177. uni.reLaunch({
  178. // url: '../course/index',
  179. url: '/pages_im/pages/conversation/conversationList/index',
  180. animationType: 'none',
  181. animationDuration: 2000
  182. });
  183. return;
  184. if(pages.length == 1) {
  185. uni.reLaunch({
  186. // url: '../course/index',
  187. url: '/pages_im/pages/conversation/conversationList/index',
  188. //url: '../course/video/living-app',
  189. animationType: 'none',
  190. animationDuration: 2000
  191. });
  192. } else {
  193. //this.$navBack();
  194. }
  195. }
  196. this.$updateMsgDot()
  197. this.$setSource()
  198. }
  199. }
  200. }
  201. </script>
  202. <style scoped lang="scss">
  203. page{
  204. background-color: #ffffff;
  205. }
  206. .other-login-btn {
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. width: 100%;
  211. height: 80rpx;
  212. background: rgba(229, 138, 0, 0.08);
  213. border-radius: 40rpx;
  214. font-size: 30rpx;
  215. font-family: PingFang SC;
  216. font-weight: 500;
  217. color: #FF5C03;
  218. border: 2rpx solid #FF5C03;
  219. margin-top: 30rpx;
  220. &::after {
  221. border: none;
  222. }
  223. }
  224. .content{
  225. display: flex;
  226. flex-direction: column;
  227. align-items: center;
  228. height: calc(100vh);
  229. width: 100%;
  230. position: relative;
  231. background: #ffffff;
  232. // justify-content: space-between;
  233. //padding-top: calc(100% - 32vh);
  234. }
  235. .backImg{
  236. position: absolute;
  237. left:30rpx;
  238. top:40px;
  239. height: 30rpx;
  240. width: 30rpx;
  241. }
  242. .pageTop{
  243. display: flex;
  244. flex-direction: column;
  245. width: 100%;
  246. margin-top: 150px;
  247. }
  248. .content .head{
  249. text-align: center;
  250. width: 100%;
  251. height: 100rpx;
  252. // background:url(/static/image/login/top_bg.png) no-repeat 0 center;
  253. background-size: cover;
  254. box-sizing: border-box;
  255. font-size: 36rpx;
  256. font-weight: bold;
  257. color: #666;
  258. }
  259. .title{
  260. color: #141414;
  261. margin:50upx 0upx 30upx 0rpx;
  262. font-size: 38rpx;
  263. font-weight: 500;
  264. }
  265. .desc{
  266. color: #686866;
  267. padding:0 0 30rpx 0rpx;
  268. font-size: 28rpx;
  269. }
  270. .loginBox{
  271. padding:0 10px 30rpx;
  272. width: calc(100%) ;
  273. background: #FDFDFD;
  274. z-index: 10;
  275. position: relative;
  276. .login-item p{
  277. text-align: left;
  278. }
  279. .line{
  280. height: 0.5rpx;
  281. background-color: #efefef;
  282. margin-top: 10rpx;
  283. }
  284. .input-account{
  285. margin-top: 20rpx;
  286. margin-bottom: 0rpx;
  287. border-radius:40rpx;
  288. border:solid 0rpx #efefef;
  289. height: 80rpx;
  290. width: 100%;
  291. background:url(/static/account.png) no-repeat 0 center;
  292. background-size: 30rpx 30rpx;
  293. background-position: 30rpx;
  294. }
  295. .input-pwd{
  296. margin-top: 40rpx;
  297. margin-bottom: 20rpx;
  298. border-radius:40rpx;
  299. border:solid 0rpx #efefef;
  300. height: 80rpx;
  301. width: 100%;
  302. background:url(/static/password.png) no-repeat 0 center;
  303. background-size: 30rpx 30rpx;
  304. background-position: 30rpx;
  305. }
  306. input{
  307. margin-left: 80rpx;
  308. height: 80rpx;
  309. line-height: 80rpx
  310. }
  311. .reg-box {
  312. padding-bottom:20rpx;
  313. margin:0 10px;
  314. .reg-btn{
  315. font-size:16px ;
  316. color: #FF5C03;
  317. }
  318. }
  319. }
  320. .btns{
  321. margin: 60rpx 0rpx;
  322. }
  323. .login-btn {
  324. display: flex;
  325. align-items: center;
  326. justify-content: center;
  327. width: 100%;
  328. height: 80rpx;
  329. background: linear-gradient(to right, #FF5C03 0%, #FF5C03 100%);
  330. background: -moz-linear-gradient(to right, #FF5C03 0%, #FF5C03 100%);
  331. box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
  332. border-radius: 40rpx;
  333. font-size: 30rpx;
  334. font-family: PingFang SC;
  335. font-weight: 500;
  336. color: rgba(255, 255, 255, 1);
  337. }
  338. </style>