123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 |
- <template>
- <view class="page">
- <view class="list_info">
- <block v-if="step == 1">
- <view class="name">请问你的性别是:</view>
- <view class="itemSex">
- <view class="sex2" :class="sex == 1 ? 'active' : ''" style="margin-right: 10rpx" @click="chkSex(1)">
- <image class="photo" src="../../static/me/sex_1.png" mode="widthFix" />
- <text>男性</text>
- </view>
- <view class="sex2" :class="sex == 2 ? 'active' : ''" style="margin-left: 10rpx" @click="chkSex(2)">
- <image class="photo" src="../../static/me/sex_2.png" mode="widthFix" />
- <text>女性</text>
- </view>
- </view>
- <view class="name">给自己取个名字吧:</view>
- <view class="item">
- <input type="text" class="input" placeholder="请输入昵称" v-model="nickname" maxlength="10" />
- </view>
- <view class="name">你的微信号是:</view>
- <view class="item">
- <input type="text" class="input" placeholder="请输入微信号" v-model="wechat" maxlength="32" />
- </view>
- <view class="name">选一张你的真实照片作为封面:</view>
- <view class="bcenter">
- <view class="avator" @click="upload">
- <image :src="avator" mode="aspectFill" class="img" />
- <image class="photo" src="../../static/me/photo.png" mode="widthFix" />
- </view>
- </view>
- </block>
- <block v-if="step == 2">
- <view class="name">给自己写一个个性签名:</view>
- <view class="item">
- <input type="text" class="input" placeholder="请输入个性签名" v-model="qianmin" maxlength="64" />
- </view>
- <view class="name">职业:</view>
- <view class="item">
- <input type="text" class="input" placeholder="请输入职业" v-model="ziye" maxlength="50" />
- </view>
- <view class="name">年龄:</view>
- <view class="itemSingle">
- <slider class="slider" :value="age" @change="sliderChange1" activeColor="#FF2A95"
- background-color="#282828" block-color="#FF2A95" block-size="12" min="10" max="100"
- show-value />
- </view>
- <view class="name">身高(CM):</view>
- <view class="itemSingle">
- <slider class="slider" :value="height" @change="sliderChange2" activeColor="#FF2A95"
- background-color="#282828" block-color="#FF2A95" block-size="12" min="150" max="220"
- show-value />
- </view>
- <view class="name">体重(KG):</view>
- <view class="itemSingle">
- <slider class="slider" :value="weight" @change="sliderChange3" activeColor="#FF2A95"
- background-color="#282828" block-color="#FF2A95" block-size="12" min="30" max="100"
- show-value />
- </view>
- </block>
- <block v-if="step == 3">
- <view class="name">学历:</view>
- <view class="item" @click="SetXueli">
- <input type="text" class="input" placeholder="请选择" v-model="xueli_sel" disabled="true" />
- <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
- </view>
- <view class="name">您的星座是:</view>
- <view class="item" @click="SetXinzuo">
- <input type="text" class="input" placeholder="请选择" v-model="xinzuo_sel" disabled="true" />
- <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
- </view>
- </block>
- <block v-if="step == 4">
- <view class="name">兴趣爱好:
- <view class="right" @click="showPop = true">添加+</view>
- </view>
- <view class="item_tag">
- <view class="tag" v-for="(item, index) in sel_tags" :key="index">
- {{ item }}
- <image class="close" src="../../static/me/close.png" mode="widthFix" @click="delTag(item)" />
- </view>
- </view>
- </block>
- <view class="blankHeight"></view>
- </view>
- <view class="btn_submit" v-if="step == 1" @click="step++">下一步</view>
- <view class="btn_list" v-if="step == 2 || step == 3">
- <view class="btn_submit1" @click="step--">上一步</view>
- <view class="btn_submit2" @click="step++">下一步</view>
- </view>
- <view class="btn_list" v-if="step == 4">
- <view class="btn_submit1" @click="step--">上一步</view>
- <view class="btn_submit2" @click="submitData()">完成</view>
- </view>
- <view class="popSel" v-if="showPop" @tap.stop="onPreview">
- <view class="list_info">
- <view class="name">你的兴趣爱好是?</view>
- <view class="desc">提示:最多选择10个兴趣爱好标签</view>
- <view class="item_tag">
- <view @tap.stop="chkTag(item)" class="tag" :class="selTags(item) ? 'active' : ''"
- v-for="(item, index) in list_tag" :key="index">
- {{ item }}
- </view>
- </view>
- </view>
- <view class="btn_submit" @click="showPop = false">提交选择</view>
- </view>
- <view class="tag_all_select">
- <view class="tag_items">
- <view v-for="(item, index) in tagList" :key="index" class="tag_item"
- :class="[item.size, { active: selectedTags.includes(index) }]" @click="selectTag(index)">
- {{ item.name }}
- </view>
- </view>
- </view>
- <view class="blankHeight"></view>
- <view class="blankHeight"></view>
- <view class="blankHeight"></view>
- <ToastW3 ref="ToastW3"></ToastW3>
- <DialogBox ref="DialogBox"></DialogBox>
- <view v-if="showRights" style="
- width: 100%;
- height: 300rpx;
- background-color: rgba(255, 255, 255, 0.9);
- position: fixed;
- top: 0;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- ">
- <text style="
- width: 90%;
- color: #000000;
- font-size: 38rpx;
- text-align: left;
- padding: 10rpx 20rpx;
- padding-top: 10rpx;
- ">正在获取相机、存储权限</text>
- <text style="
- width: 90%;
- color: #666666;
- font-size: 28rpx;
- text-align: left;
- padding: 10rpx 20rpx;
- ">该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</text>
- </view>
- </view>
- </template>
- <script>
- import {
- requestAndroidPermission,
- gotoAppPermissionSetting,
- } from "../index/permission.js";
- export default {
- components: {},
- data() {
- return {
- showRights: false,
- title: "",
- step: 1,
- sel: 1,
- info: {},
- showPop: false,
- nickname: "",
- wechat: "",
- sex: 1,
- age: 18,
- height: 160,
- weight: 50,
- avator: "../../static/me/avator.png",
- ziye: "",
- qianmin: "",
- xueli_sel: "",
- xueli: [
- "初中",
- "初中",
- "中专",
- "高中",
- "专科",
- "本科",
- "研究生",
- "硕士",
- "博士",
- ],
- xinzuo_sel: "",
- xinzuo: [
- "水瓶座",
- "双鱼座",
- "白羊座",
- "金牛座",
- "双子座",
- "巨蟹座",
- "狮子座",
- "处女座",
- "天秤座",
- "天蝎座",
- "射手座",
- "摩羯座",
- ],
- list_tag: ["篮球", "排球", "足球", "羽毛球", "健身达人", "美食达人"],
- sel_tags: [],
- selectedTags: [],
- tagList: [
- { name: "游戏", size: "large" },
- { name: "音乐", size: "medium" },
- { name: "盲盒", size: "large" },
- { name: "小可爱", size: "small" },
- { name: "娃娃人", size: "medium" },
- { name: "纹身", size: "large" },
- { name: "洛丽塔", size: "small" },
- { name: "女装", size: "medium" },
- { name: "萌球", size: "small" },
- ],
- };
- },
- onLoad() {
- this.step = 1;
- let tagStr =
- "篮球、羽毛球、兵乓球、足球、滑板、滑旱冰、跑步、跳绳、举重、听音乐、看电影、绘画、写小说、看书、做弹弓玩、做木剑玩、做橡皮枪玩、积木、用麻将搭金字塔、拼图、拆装、扑克牌、小汽车、手表、鞋之类的、弹吉他、钢琴、萨克斯、葫芦丝、大号、小号、折纸、剪纸、品茶、涂鸦、英雄联盟、qq堂、cs、cf、地下城勇士、桌面游戏";
- this.list_tag = tagStr.split("、");
- this.getInfoData();
- },
- onShow() { },
- methods: {
- onBack() { },
- chkSel() {
- if (this.sel == 1) {
- this.sel = 0;
- } else {
- this.sel = 1;
- }
- },
- chkSex(sex) {
- this.sex = sex;
- },
- delTag(tg) {
- let list_tag2 = [];
- for (let i = 0; i < this.sel_tags.length; i++) {
- if (this.sel_tags[i] != tg && this.sel_tags[i] != "") {
- list_tag2.push(this.sel_tags[i]);
- }
- }
- this.sel_tags = list_tag2;
- },
- selTags(itm) {
- let that = this;
- let isIn = false;
- for (let entry of this.sel_tags) {
- // console.log(entry); // 1, "string", false
- if (entry == itm) {
- isIn = true;
- break;
- }
- }
- return isIn;
- },
- chkTag(itm) {
- if (this.selTags(itm)) {
- let tmpTags = [];
- for (let entry of this.sel_tags) {
- // console.log(entry); // 1, "string", false
- if (entry != itm && entry != "") {
- tmpTags.push(entry);
- }
- }
- this.sel_tags = tmpTags;
- } else {
- if (this.sel_tags.length >= 10) {
- this.$refs["ToastW3"].showToast({
- title: "最多选择10个标签",
- animation: 0,
- });
- return;
- }
- this.sel_tags.push(itm);
- }
- },
- sliderChange1(e) {
- this.age = e.detail.value;
- },
- sliderChange2(e) {
- this.height = e.detail.value;
- },
- sliderChange3(e) {
- this.weight = e.detail.value;
- },
- SetXueli() {
- let that = this;
- uni.showActionSheet({
- itemColor: "#000000",
- itemList: this.xueli,
- success: function (res) {
- that.xueli_sel = that.xueli[res.tapIndex];
- // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
- },
- fail: function (res) {
- console.log(res.errMsg);
- },
- });
- },
- SetXinzuo() {
- let that = this;
- uni.showActionSheet({
- itemColor: "#000000",
- itemList: this.xinzuo,
- success: function (res) {
- that.xinzuo_sel = that.xinzuo[res.tapIndex];
- // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
- },
- fail: function (res) {
- console.log(res.errMsg);
- },
- });
- },
- getInfoData() {
- console.log(this.$apiHost + "/Member/getinfoData");
- uni.request({
- url: this.$apiHost + "/Member/getinfoData", //仅为示例,并非真实接口地址。
- data: {
- uuid: getApp().globalData.uuid,
- },
- header: {
- "content-type": "application/json", //自定义请求头信息
- },
- success: (res) => {
- console.log("res", res.data);
- this.nickname = res.data.nickname;
- this.wechat = res.data.wechat;
- this.sex = res.data.sex || 2;
- this.age = res.data.age || 18;
- this.height = res.data.height || 160;
- this.weight = res.data.weight || 50;
- this.xueli_sel = res.data.xueli;
- this.xinzuo_sel = res.data.xinzuo;
- this.ziye = res.data.ziye;
- this.qianmin = res.data.qianmin;
- if (res.data.avator != "") {
- this.avator = res.data.avator;
- }
- if (res.data.aihao != null && res.data.aihao != undefined) {
- if (res.data.aihao.length > 0) {
- this.sel_tags = res.data.aihao.split(",");
- }
- }
- },
- });
- },
- submitData() {
- let aihao = this.sel_tags.join(",");
- let obj2 = {
- uuid: getApp().globalData.uuid,
- avator: this.avator,
- nickname: this.nickname,
- wechat: this.wechat,
- sex: this.sex,
- age: this.age,
- height: this.height,
- weight: this.weight,
- xueli: this.xueli_sel,
- xinzuo: this.xinzuo_sel,
- ziye: this.ziye,
- qianmin: this.qianmin,
- aihao: aihao,
- };
- // console.log("obj2", obj2);
- uni.request({
- url: this.$apiHost + "/Member/setinfoData", //仅为示例,并非真实接口地址。
- data: obj2,
- method: "POST",
- header: {
- "Content-Type": "application/x-www-form-urlencoded",
- sign: getApp().globalData.headerSign,
- },
- dataType: "json",
- // header: {
- // 'content-type': 'application/json', //自定义请求头信息
- // 'Access-Control-Allow-Origin': '*'
- // },
- success: (res) => {
- console.log("res", res.data);
- this.$refs["ToastW3"].showToast({
- title: res.data.str,
- animation: 0,
- });
- if (res.data.success == "yes") {
- uni.switchTab({
- url: "/pages/index/index",
- });
- }
- },
- });
- },
- // upload() {
- // let that = this;
- // this.$refs['DialogBox'].confirm({
- // title: '提示',
- // content: '该权限用于获取设备拍摄或获取本地应用相册,进行头像的图片上传。',
- // DialogType: 'inquiry',
- // btn1: '拒绝',
- // btn2: '同意',
- // animation: 0
- // }).then((res) => {
- // that.upload2();
- // })
- // },
- upload() {
- this.checkRights();
- console.log("----upload");
- var _self = this;
- uni.chooseImage({
- count: 1,
- sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ["album", "camera"], //从相册、相机选择
- extension: [".png", ".jpeg", ".jpg"],
- success: function (res) {
- console.log("res:", res);
- _self.imglocal = res.tempFilePaths[0];
- const tempFilePaths = res.tempFilePaths[0];
- console.log("tempFilePaths:", tempFilePaths);
- // 图片上传
- const uploadTask = uni.uploadFile({
- url: _self.$apiHost + "/Xweb/upload_img?skey=" + _self.skey, // post请求地址
- filePath: res.tempFilePaths[0],
- name: "file", // 待确认
- success: function (uploadFileRes) {
- let resdata = JSON.parse(uploadFileRes.data);
- console.log("Success11:", uploadFileRes);
- console.log("Success21:", resdata);
- if (resdata.success == "yes") {
- _self.avator = resdata.url;
- }
- },
- fail: function (uploadFileFail) {
- console.log("Error:", uploadFileFail.data);
- },
- complete: () => {
- console.log("Complete:");
- },
- });
- },
- error: function (e) {
- console.log(e);
- },
- });
- },
- checkRights() {
- let that = this;
- that.showRights = true;
- requestAndroidPermission("android.permission.CAMERA")
- .then((result) => {
- that.showRights = false;
- // 根据返回的结果进行处理
- if (result === 1) {
- } else if (result === 0) {
- console.log("权限被拒绝");
- } else if (result === -1) {
- console.log("权限被永久拒绝");
- }
- })
- .catch((error) => {
- that.showRights = true;
- console.log("权限申请失败:", error);
- });
- },
- selectTag(index) {
- const tagIndex = this.selectedTags.indexOf(index);
- if (tagIndex === -1) {
- // 如果未选中,则添加到选中数组
- this.selectedTags.push(index);
- } else {
- // 如果已选中,则从数组中移除
- this.selectedTags.splice(tagIndex, 1);
- }
- },
- },
- };
- </script>
- <style scoped lang="scss">
- @import "normal.scss";
- .popSel {
- position: fixed;
- z-index: 999999;
- top: 0;
- left: 0;
- background-color: #121212;
- width: 100vh;
- height: 100vh;
- }
- .tag_all_select {
- padding: 20rpx;
- .tag_items {
- display: flex;
- flex-wrap: wrap;
- gap: 30rpx;
- justify-content: center;
- align-items: center;
- .tag_item {
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 50%;
- background: rgba(255, 255, 255, 0.1);
- color: #fff;
- font-size: 26rpx;
- transition: all 0.3s ease;
- cursor: pointer;
- &.small {
- width: 120rpx;
- height: 120rpx;
- }
- &.medium {
- width: 160rpx;
- height: 160rpx;
- font-size: 28rpx;
- }
- &.large {
- width: 200rpx;
- height: 200rpx;
- font-size: 32rpx;
- }
- &.active {
- transform: scale(1.2);
- background: rgba(255, 255, 255, 0.2);
- box-shadow: 0 0 20rpx rgba(255, 255, 255, 0.3);
- z-index: 1;
- }
- &:not(.active):hover {
- transform: scale(1.05);
- }
- }
- }
- }
- </style>
|