用工小程序前端代码
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.

145 lines
3.6 KiB

8 months ago
6 months ago
5 months ago
6 months ago
5 months ago
8 months ago
5 months ago
8 months ago
5 months ago
8 months ago
5 months ago
8 months ago
5 months ago
8 months ago
5 months ago
6 months ago
5 months ago
6 months ago
8 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
8 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 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" @blur="bindblur"
  23. 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>
  26. <view class="se-mx-40">
  27. <view @click="onUpdateInfo"
  28. 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-green">
  29. 确认
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. appletLogin
  37. } from "@/common/api.js"
  38. export default {
  39. name: 'Login',
  40. data() {
  41. return {
  42. nameUser: "",
  43. imagUrl: "",
  44. phone: "",
  45. back: 0
  46. }
  47. },
  48. onLoad(options) {
  49. if (options.back == 1) {
  50. this.imagUrl = uni.getStorageSync('userInfo').headImage
  51. this.nameUser = uni.getStorageSync('userInfo').nickName
  52. this.phone = uni.getStorageSync('userInfo').phone
  53. this.back = options.back
  54. }
  55. },
  56. methods: {
  57. bindblur(event) {
  58. this.nameUser = event.target.value
  59. },
  60. onChooseAvatar(res) {
  61. console.log("获取头像消息", res)
  62. // let self = this
  63. // self.$Oss.ossUpload(res.target.avatarUrl).then(url => {
  64. // self.imagUrl = url
  65. // })
  66. },
  67. onPhonenumber(event) {
  68. let that = this
  69. var detail = event.detail;
  70. if (detail.errMsg == 'getPhoneNumber:ok') {
  71. let params = {
  72. code: detail.code,
  73. encryptedData: detail.encryptedData,
  74. iv: detail.iv,
  75. sessionKey: uni.getStorageSync('sessionKey'),
  76. openid: uni.getStorageSync('userInfo').appletOpenid
  77. }
  78. bindPhone(params).then((response) => {
  79. console.info(response)
  80. that.phone = response.result
  81. }).catch(error => {
  82. })
  83. }
  84. },
  85. onUpdateInfo() {
  86. let that = this
  87. uni.showLoading({
  88. title: '保存中...'
  89. })
  90. uni.login({
  91. success(res) {
  92. console.info(res.code)
  93. if (res.errMsg != "login:ok") {
  94. return
  95. }
  96. let params = {
  97. code: res.code,
  98. headimgurl: that.imagUrl,
  99. nickName: that.nameUser,
  100. openid: uni.getStorageSync('userInfo').appletOpenid
  101. // phone:that.phone
  102. }
  103. // &&that.phone
  104. if (that.imagUrl && that.nameUser) {
  105. appletLogin(params).then((response) => {
  106. if (this.back == 1) {
  107. uni.navigateBack({
  108. delta: 1
  109. })
  110. } else {
  111. uni.navigateTo({
  112. url: "/pages/identity/index"
  113. })
  114. }
  115. }).catch((error) => {
  116. })
  117. } else {
  118. return uni.showToast({
  119. icon: "none",
  120. title: "头像和昵称不能为空!"
  121. })
  122. }
  123. }
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped lang="scss">
  130. .default-btn {
  131. background-color: #fff;
  132. }
  133. .default-btn::after {
  134. content: "";
  135. border: none;
  136. }
  137. </style>