wxinfo.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view>
  3. <u-modal :show="showAuthorizeUser" :show-title="false" :show-confirm-button="false">
  4. <view class="slot-content">
  5. <div class="auth-card">
  6. <div class="img">
  7. <img class="avatar-img" :src="logo" mode="widthFix">
  8. </div>
  9. <div class="title">{{bname}}</div>
  10. <div class="content">邀请您补全个人信息<br></br>(昵称、头像)</div>
  11. <div style="margin-left: 100rpx;margin-right: 100rpx">
  12. <u-form :model="user" ref="uForm">
  13. <u-form-item label="头像">
  14. <view style="width:300rpx; height: 100rpx;">
  15. <button class="avatar-wrapper" open-type="chooseAvatar"
  16. @chooseavatar="onChooseAvatar" slot="right">
  17. <image class="avatar" :src="user.headimgurl"></image>
  18. </button>
  19. </view>
  20. </u-form-item>
  21. <u-form-item label="昵称">
  22. <input type="nickname" class="weui-input" @blur="userNameInput" placeholder="请输入昵称" />
  23. </u-form-item>
  24. </u-form>
  25. </div>
  26. </div>
  27. <div class="auth-btncard">
  28. <div class="btn-unok">
  29. <u-button :hair-line='false' :custom-style="customStyleUnOk" @click="showAuthorizeUser=false">
  30. 拒绝</u-button>
  31. </div>
  32. <div class="btn-ok">
  33. <u-button :hair-line='false' :custom-style="customStyleOk" @click="authUser"> 允许</u-button>
  34. </div>
  35. </div>
  36. </view>
  37. </u-modal>
  38. </view>
  39. </template>
  40. <script>
  41. import loginApi from '@/api/login/login.js';
  42. import mineApi from '@/api/mine/index.js';
  43. export default {
  44. name: "nologin",
  45. props: [],
  46. data() {
  47. return {
  48. user: {
  49. headimgurl: 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0',
  50. nickname: '',
  51. },
  52. hasUserInfo: false,
  53. logo: '',
  54. // 用户基本信息
  55. userInfo: null,
  56. // 微信,支付宝用户code
  57. code: '',
  58. // 是否弹出登录注册授权弹窗
  59. showAuthorizeUser: false,
  60. showAuthorizePhone: false,
  61. };
  62. },
  63. methods: {
  64. open() {
  65. if (this.$config.shop && this.$config.shop.logo) {
  66. this.logo = this.$config.shop.logo
  67. } else {
  68. this.logo = this.user.headimgurl
  69. }
  70. this.showAuthorizeUser = true
  71. },
  72. //获取昵称输入内容
  73. userNameInput(e) {
  74. this.user.nickname = e.detail.value
  75. },
  76. onChooseAvatar(e) {
  77. let that = this;
  78. that.user.headimgurl = e.detail.avatarUrl;
  79. console.log('this.user.headimgurl1', this.user.headimgurl)
  80. uni.getFileSystemManager().readFile({
  81. filePath: that.user.headimgurl, //选择图片返回的相对路径
  82. encoding: 'base64', //编码格式
  83. success: v => {
  84. //成功的回调
  85. let base64 = 'data:image/jpeg;base64,' + v
  86. .data; // 返回的是没有 'data:image/jpeg;base64,'头的数据, 有需要可自行追加上
  87. mineApi.addheadimg({
  88. pic: base64
  89. })
  90. .then(res => {
  91. if (res.status == 200) {
  92. that.user.headimgurl = res.data;
  93. console.log('that.user.headimgurl2', that.user.headimgurl)
  94. }
  95. });
  96. }
  97. });
  98. },
  99. chooseAvatar() {
  100. let that = this;
  101. function guid2() {
  102. function S4() {
  103. return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  104. }
  105. return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
  106. }
  107. let token = uni.getStorageSync('token') || '';
  108. let timestamp = parseInt(new Date().getTime() / 1000);
  109. let sign = 'getSign'(data);
  110. let uniqueid = guid2();
  111. uni.chooseImage({
  112. count: 1, //默认9
  113. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  114. success: function(res) {
  115. console.log(res, 'resresres')
  116. uni.getFileSystemManager().readFile({
  117. filePath: res.tempFilePaths[0], //选择图片返回的相对路径
  118. encoding: 'base64', //编码格式
  119. success: v => {
  120. //成功的回调
  121. let base64 = 'data:image/jpeg;base64,' + v
  122. .data; // 返回的是没有 'data:image/jpeg;base64,'头的数据, 有需要可自行追加上
  123. mineApi.addheadimg({
  124. pic: base64
  125. })
  126. .then(res => {
  127. if (res.status == 200) {
  128. this.user.headimgurl = res.data;
  129. }
  130. });
  131. }
  132. });
  133. }
  134. });
  135. },
  136. authUser() {
  137. let that = this;
  138. let userInfo = uni.getStorageSync('userInfo')
  139. if (that.user.nickname == '') {
  140. that.$api.msg('请输入您的昵称!');
  141. return;
  142. }
  143. userInfo.headimgurl = that.user.headimgurl;
  144. userInfo.nickname = that.user.nickname;
  145. that.userInfo = userInfo;
  146. uni.setStorageSync('userInfo', userInfo)
  147. that.user.id = userInfo.id;
  148. loginApi.upuserinfo(that.user).then(res => {
  149. if (res.status == 200) {
  150. that.hasUserInfo = true;
  151. that.showAuthorizeUser = false;
  152. that.$emit('loginback');
  153. } else {
  154. uni.showToast({
  155. title: res.msg,
  156. icon: 'none'
  157. })
  158. }
  159. })
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. .auth-btncard {
  166. .btn-unok {
  167. width: 50%;
  168. float: left;
  169. }
  170. .btn-ok {
  171. width: 50%;
  172. float: left;
  173. margin: 0;
  174. padding: 0;
  175. border: 0px solid transparent; //自定义边框
  176. outline: none; //消除默认点击蓝色边框效果
  177. u-button {
  178. margin: 0;
  179. padding: 0;
  180. border: 0px solid transparent; //自定义边框
  181. outline: none; //消除默认点击蓝色边框效果
  182. }
  183. }
  184. }
  185. .auth-card {
  186. text-align: center;
  187. .avatar-img {
  188. width: 150rpx;
  189. height: 150rpx;
  190. overflow: hidden;
  191. border-radius: 100%;
  192. margin-top: 30rpx;
  193. }
  194. .title {
  195. font-size: 20rpx;
  196. }
  197. .content {
  198. margin-top: 10rpx;
  199. }
  200. }
  201. .mine_box {
  202. height: 360upx;
  203. color: #fff;
  204. // background-color: $primarycolor;
  205. .avatar-img {
  206. width: 150rpx;
  207. height: 150rpx;
  208. overflow: hidden;
  209. border-radius: 100%;
  210. /*margin-right: 40rpx;*/
  211. }
  212. .avatar_box {
  213. position: relative;
  214. width: 150rpx;
  215. height: 150rpx;
  216. overflow: hidden;
  217. border-radius: 100%;
  218. margin-right: 40rpx;
  219. .avatar-img {
  220. width: 100%;
  221. height: 100%;
  222. /* #ifdef MP-WEIXIN*/
  223. width: 150rpx;
  224. height: 150rpx;
  225. /* #endif */
  226. }
  227. .get_user_data {
  228. z-index: 11;
  229. opacity: 0;
  230. width: 100%;
  231. height: 100%;
  232. position: absolute;
  233. left: 0;
  234. top: 0;
  235. }
  236. }
  237. .nick-name-box {
  238. height: 100%;
  239. }
  240. .user-nickName {
  241. font-size: 40rpx;
  242. color: #fff;
  243. margin-bottom: 20rpx;
  244. }
  245. .shiming_box {
  246. border-radius: 10upx;
  247. font-size: 28upx;
  248. padding: 10upx 20upx;
  249. background-color: rgba(15, 77, 139, 0.5);
  250. .icon-shezhi {
  251. margin-right: 10rpx;
  252. margin-top: 5rpx;
  253. }
  254. }
  255. }
  256. .authorize-box {
  257. background-color: transparent;
  258. text-align: center;
  259. .authorize-avatar {
  260. width: 200rpx;
  261. height: 200rpx;
  262. }
  263. .authorize-btn {
  264. position: relative;
  265. top: 40rpx;
  266. }
  267. }
  268. /deep/.u-mode-center-box {
  269. background-color: transparent !important;
  270. }
  271. </style>
  272. <style>
  273. .avatar-wrapper {
  274. width: 150rpx;
  275. height: 100rpx;
  276. color: #333 !important;
  277. text-align: center !important;
  278. border: none !important;
  279. border-radius: 0 !important;
  280. background-color: transparent !important;
  281. }
  282. .avatar-wrapper::after {
  283. border: none !important;
  284. }
  285. .avatar {
  286. margin-right: 50rpx;
  287. width: 100rpx;
  288. height: 100rpx;
  289. overflow: hidden;
  290. border-radius: 100%;
  291. }
  292. </style>