用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.5 KiB

6 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
4 months ago
6 months ago
6 months ago
3 months ago
6 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
6 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
6 months ago
4 months ago
6 months ago
  1. <template>
  2. <view>
  3. <view class="se-pt-200 se-flex se-flex-h-c se-flex-ff-cw">
  4. <image class="se-w-150 se-h-150" src="@/static/image/logo.png" mode=""></image>
  5. <view class="se-flex se-flex-h-c se-fs-34 se-fw-6 se-c-black se-mt-40">
  6. 智选猎头
  7. </view>
  8. <view class="se-mt-20 se-fs-26 se-c-black se-flex se-flex-h-c">
  9. 申请获取您的头像昵称
  10. </view>
  11. </view>
  12. <view class="se-mx-40 se-py-100">
  13. <view class="se-b-t se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
  14. <text>头像</text>
  15. <button class="se-w-100 se-h-100 se-p-0 se-m-0" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  16. <image v-if="imagUrl" class="se-w-100 se-h-100" :src="imagUrl"></image>
  17. <image v-else class="se-w-100 se-h-100" src="@/static/image/header.png" mode=""></image>
  18. </button>
  19. </view>
  20. <view class=" se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
  21. <text>昵称</text>
  22. <input type="nickname" placeholder="请输入昵称" v-model="nameUser"
  23. @blur="bindblur" class="se-h-80 se-lh-80 se-w-320 se-fs-24 se-ta-r" placeholder-class="se-fs-24 se-ta-r" />
  24. </view>
  25. <view class=" se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
  26. <text>手机号</text>
  27. <button v-if="phone" class="default-btn se-h-100 se-p-0 se-m-0" open-type="getPhoneNumber" @getphonenumber="onPhonenumber">{{phone}}</button>
  28. <button v-else class="se-w-140 se-h-60 se-lh-60 se-fs-20 se-bgc-orange se-c-white se-py-0 se-br-30 se-px-20 se-m-0" open-type="getPhoneNumber" @getphonenumber="onPhonenumber">
  29. 获取手机号
  30. </button>
  31. </view>
  32. </view>
  33. <view class="se-mx-40">
  34. <view @click="onUpdateInfo" class="se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-white se-bgc-orange">
  35. 确认
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { updateUserInfo,bindPhone,userInfo,getSessionKey } from "@/common/api.js"
  42. export default {
  43. name : 'Login',
  44. data() {
  45. return {
  46. nameUser:"",
  47. imagUrl:"",
  48. phone:"",
  49. back:0,
  50. code:""
  51. }
  52. },
  53. onLoad(options) {
  54. console.info(options)
  55. // this.onSessionKey()
  56. if(options.back==1){
  57. this.back = options.back
  58. this.onUserInfo()
  59. }
  60. },
  61. methods: {
  62. onSessionKey(){
  63. // let that = this
  64. // uni.login({
  65. // success(res) {
  66. // that.code = res.code
  67. // getSessionKey({code:res.code}).then(response=>{
  68. // uni.setStorageSync('sessionKey',response.result)
  69. // }).catch(error=>{
  70. // })
  71. // }
  72. // })
  73. },
  74. onUserInfo(){
  75. let params={}
  76. userInfo(params).then(response=>{
  77. this.imagUrl=response.result.headImage
  78. this.nameUser=response.result.nickName?response.result.nickName:"微信昵称"
  79. this.phone=response.result.phone?response.result.phone:""
  80. }).catch(error=>{
  81. })
  82. },
  83. bindblur(event) {
  84. this.nameUser = event.target.value
  85. },
  86. onChooseAvatar(res) {
  87. let self = this
  88. self.$Oss.ossUpload(res.target.avatarUrl).then(url => {
  89. self.imagUrl = url
  90. })
  91. },
  92. onPhonenumber(event){
  93. let that = this
  94. var detail = event.detail;
  95. if(detail.errMsg=='getPhoneNumber:ok'){
  96. let params={
  97. phoneCode : detail.code,
  98. encryptedData: detail.encryptedData,
  99. iv:detail.iv,
  100. }
  101. bindPhone(params).then((response) => {
  102. console.info(response)
  103. let obj = JSON.parse(response.result)
  104. that.phone = obj.phone_info.phoneNumber
  105. }).catch(error=>{
  106. })
  107. }
  108. },
  109. onUpdateInfo(){
  110. let that = this
  111. uni.showLoading({
  112. title: '保存中...'
  113. })
  114. uni.login({
  115. success(res) {
  116. console.info(res.code)
  117. if(res.errMsg != "login:ok"){
  118. return
  119. }
  120. let params={
  121. code : res.code,
  122. headImage:that.imagUrl,
  123. nickName:that.nameUser,
  124. openid:uni.getStorageSync('userInfo').appletOpenid,
  125. phone:that.phone
  126. }
  127. //
  128. if(that.imagUrl&&that.nameUser&&that.phone){
  129. updateUserInfo(params).then((response) => {
  130. if(that.back==1){
  131. uni.navigateBack({
  132. delta:1
  133. })
  134. }else{
  135. uni.navigateTo({
  136. url:"/pages/identity/index"
  137. })
  138. }
  139. }).catch((error) =>{
  140. })
  141. }else{
  142. return uni.showToast({
  143. icon:"none",
  144. title:"头像,昵称和手机号不能为空!"
  145. })
  146. }
  147. }
  148. })
  149. }
  150. }
  151. }
  152. </script>
  153. <style scoped lang="scss">
  154. .default-btn{
  155. background-color: #fff;
  156. }
  157. .default-btn::after{
  158. content: "";
  159. border: none;
  160. }
  161. </style>