loginPop.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view>
  3. <u-popup :show="userlogo" mode="bottom" round='12'>
  4. <view class="userlogo column">
  5. <view class="mtb30 justify-start align-center ml20">
  6. <u-avatar :src="imgPath+'/app/image/logo.png'" size="50"></u-avatar>
  7. <view class="bold mlr20">{{imgname}}</view>
  8. <view>申请</view>
  9. </view>
  10. <view class="bold fs36 ml20">授权你的昵称头像信息</view>
  11. <view class="mtb20 justify-between align-center plr20">
  12. <view class="justify-start align-center">
  13. <view class="boxweixin" :class="userinfos.nickname==''?'boxnosel':'boxsel'">
  14. <view v-if="userinfos.nickname">√</view>
  15. </view>
  16. <view class="ml20">
  17. <view class="base-color-3 bold">第一步</view>
  18. <view class="fs32 base-color-9">请点击授权微信昵称</view>
  19. </view>
  20. </view>
  21. <view class="button-container">
  22. <input
  23. type="nickname"
  24. class="hidden-input"
  25. @blur="onNickNameInput"
  26. @input="onNickNameInput"
  27. />
  28. <button class="custom-button" :class="nameuser==''?'subname':'subavt'">{{nameuser?"已授权":'允许授权'}}</button>
  29. </view>
  30. </view>
  31. <view class="mtb20 justify-between align-center plr20 mt40">
  32. <view class="justify-start align-center">
  33. <view class="boxweixin" :class="userinfos.nickname==''?'boxnosel':'boxsel'">
  34. <view v-if="userinfos.avatar">√</view>
  35. </view>
  36. <view class="ml20">
  37. <view class="base-color-3 bold">第二步</view>
  38. <view class="fs32 base-color-9">请点击授权微信头像</view>
  39. </view>
  40. </view>
  41. <view class="button-container">
  42. <button open-type="chooseAvatar" @chooseavatar="onChooseAvatar" class="hidden-input"
  43. v-if="nameuser">
  44. 允许授权
  45. </button>
  46. <button class="custom-button sub" @click="shouquan" v-if="nameuser==''">允许授权</button>
  47. <button class="custom-button " :class="avataruser==''?'subname':'subavt'"
  48. v-else>{{avataruser?"已授权":'允许授权'}}</button>
  49. </view>
  50. </view>
  51. <view class="submitname" @click="confimrname" :class="nameuser&&avataruser?'subact':'sub'">确定</view>
  52. </view>
  53. </u-popup>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. userlogo:false,
  61. projectId:'',
  62. userinfos:{
  63. nickname:"",
  64. avatar:""
  65. },
  66. headImg:'',
  67. authType:0,//0微信登录 1手机号登录
  68. userdisabled:false,
  69. }
  70. },
  71. computed: {
  72. isAnswer() {
  73. return (item, name) => {
  74. if (item.type == 1) {
  75. return item.answer == name
  76. } else if (item.type == 2) {
  77. const array = item.answer.split(',')
  78. return array.some(i => i == name)
  79. } else {
  80. return false
  81. }
  82. }
  83. },
  84. imgPath() {
  85. return this.$store.state.imgpath
  86. },
  87. imgname() {
  88. return this.$store.state.logoname
  89. },
  90. appid() {
  91. return this.$store.state.appid
  92. },
  93. nameuser() {
  94. return this.userinfos.nickname
  95. },
  96. avataruser() {
  97. return this.userinfos.avatar
  98. },
  99. },
  100. methods: {
  101. shouquan(){
  102. if(this.userinfos.nickname==''){
  103. uni.showToast({
  104. icon:'none',
  105. title: "请先授权微信昵称",
  106. });
  107. }
  108. },
  109. confimrname(){
  110. if(this.userinfos.nickname==''){
  111. uni.showToast({
  112. icon:'none',
  113. title: "请授权微信昵称",
  114. });
  115. return
  116. }
  117. if(this.userinfos.avatar==''){
  118. uni.showToast({
  119. icon:'none',
  120. title: "请授权微信头像",
  121. });
  122. return
  123. }
  124. uni.setStorageSync('userInfos',this.userinfos)
  125. this.editUserA()
  126. this.userlogo=false
  127. },
  128. onChooseAvatar(e){
  129. this.userinfos.avatar=e.detail.avatarUrl
  130. uni.uploadFile({
  131. url: uni.getStorageSync('requestPath')+'/app/common/uploadOSS', //仅为示例,非真实的接口地址
  132. filePath: e.detail.avatarUrl,
  133. name: 'file',
  134. formData: {
  135. 'user': 'test' // 上传附带参数
  136. },
  137. success: (uploadFileRes) => {
  138. console.log(uploadFileRes)
  139. // 根据接口具体返回格式 赋值具体对应url
  140. var data=JSON.parse(uploadFileRes.data)
  141. this.headImg=uni.getStorageSync('requestPath')+data.fileName
  142. this.userinfos.avatar=data.url
  143. }
  144. });
  145. },
  146. onNickNameInput(e){
  147. console.log(e)
  148. this.userinfos.nickname=e.detail.value
  149. },
  150. async loginFsUserWx(data){
  151. if(data){
  152. console.log('huoqu1222',data)
  153. uni.showLoading({
  154. title: '加载中'
  155. })
  156. uni.login({
  157. provider: "weixin",
  158. success: async loginRes => {
  159. console.log(loginRes)
  160. let code = loginRes.code // 获取开发code
  161. handleFsUserWx({
  162. code: code,
  163. appId:this.appid,
  164. userId:data.userId
  165. })
  166. .then( res => {
  167. if(res.code==200){
  168. console.log(res)
  169. uni.hideLoading();
  170. uni.showToast({
  171. icon:'none',
  172. title: "登录成功",
  173. });
  174. this.userinfos=uni.getStorageSync('userinfos')
  175. uni.getStorageSync('TOKEN_WEXIN');
  176. this.userInfo=uni.getStorageSync('userInfo');
  177. this.isLogin = true
  178. setTimeout(()=>{
  179. this.getIsAddKf()
  180. },200)
  181. }else if(res.code==406){
  182. uni.hideLoading();
  183. uni.showToast({
  184. icon:'none',
  185. title: '该用户已成为其他销售会员',
  186. });
  187. }else{
  188. uni.hideLoading();
  189. uni.showToast({
  190. icon:'none',
  191. title: res.msg,
  192. });
  193. }
  194. })
  195. },
  196. })
  197. }else{
  198. await this.$store.dispatch('getWebviewUrl');
  199. uni.navigateTo({
  200. url:'/pages_course/webview?H5course='+uni.getStorageSync('H5course')
  201. })
  202. }
  203. }
  204. }
  205. }
  206. </script>
  207. <style scoped lang="scss">
  208. .subname{
  209. background-color: #00aa00;
  210. color: #fff;
  211. }
  212. .subavt{
  213. background-color: #fff;
  214. border: 2rpx #0a0 solid;
  215. color: #00aa00;
  216. }
  217. .boxweixin{
  218. width: 44rpx;
  219. height: 44rpx;
  220. border-radius: 50%;
  221. text-align: center;
  222. line-height: 34rpx;
  223. color: #0a0;
  224. }
  225. .boxnosel{
  226. border: #757575 4rpx solid;
  227. }
  228. .boxsel{
  229. border: #0a0 4rpx solid;
  230. }
  231. .button-container {
  232. position: relative;
  233. width: 240rpx;
  234. }
  235. .hidden-input {
  236. position: absolute;
  237. top: 0;
  238. left: 0;
  239. width: 100%;
  240. height: 100%;
  241. opacity: 0;
  242. z-index: 2;
  243. }
  244. .custom-button {
  245. position: relative;
  246. z-index: 1;
  247. /* 其他样式 */
  248. width:100%;
  249. margin: 0 auto;
  250. height: 80rpx;
  251. line-height: 60rpx;
  252. font-size: 28rpx;
  253. padding: 10rpx 20rpx;
  254. }
  255. .submitname{
  256. width: 90%;
  257. margin: 0 auto;
  258. text-align: center;
  259. padding: 30rpx;
  260. margin-top: 40rpx;
  261. }
  262. .sub{
  263. background-color: #f0f0f0;
  264. color: #0a0;
  265. }
  266. .subact{
  267. background-color: #0a0;
  268. color: #fff;
  269. }
  270. .userlogo{
  271. height: 760rpx;
  272. }
  273. </style>