个人编辑页页处理记录

<!--

* @Descripttion:

* @version:

* @Author: Alex

* @Date: 2020-05-12 15:43:17

* @LastEditors: Alex

* @LastEditTime: 2020-07-04 10:27:58

-->

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>user-info</title>

<link rel="stylesheet" href="./css/pulic.css">

<link rel="stylesheet" href="./css/user-info.css" />

<link rel="stylesheet" href="./css/iosSelect.css" />

</head>

<body>

<div id="app" v-cloak>

<form action="" method="post">

<input type="file" ref="imgfile" @change="upfile" style="display: none;" accept="image/*">

<!--  -->

<!--  -->

<!--  -->

<div class="list-layout">

<div class="title-box">

个人信息

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">头像</div>

<div class="item-content flex" @click="handfile('avatar')">

<div class="item-pic">

<img :src="avatarUrl" alt="">

</div>

<div class="item-icon"></div>

</div>

</div>

<!--  -->

<div class="list-item-box flex" v-if="form.live_image">

<div class="item-title">直播封面图</div>

<div class="item-content flex" @click="handfile('live_image')">

<div class="item-pic">

<img :src="live_imageUrl" alt="">

</div>

<div class="item-icon"></div>

</div>

</div>

<!--  -->

<div class="list-item-box flex" v-if="form.chat_image">

<div class="item-title">房间背景</div>

<div class="item-content flex" @click="handfile('chat_image')">

<div class="item-pic">

<img :src="chat_imageUrl" alt="">

</div>

<div class="item-icon"></div>

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">昵称</div>

<div class="item-content flex">

<input type="text" placeholder="昵称" v-model="form.nickname">

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">性别<span class="sex-tip">(不可修改)</span></div>

<div class="item-content flex" v-show="form.genderlist != 0 ">

<div class="item-sex-icon" :class="[form.genderlist == 1 ? 'item-boy':'item-girl']"></div>

<div class="item-text">{{ form.genderlist == 1 ? '男':'女' }}</div>

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">生日<span class="sex-tip">(不可修改)</span></div>

<div class="item-content flex" id="birthday">

<div class="item-check-title">{{ form.birthday }}</div>

<!-- <div class="item-icon"></div> -->

</div>

</div>

<!-- @click="openSelect('height',heigthList)" -->

<div class="list-item-box flex">

<div class="item-title">身高</div>

<div class="item-content flex" ref='height' @click="openSelect('height',heigthList)">

<div class="item-check-title">{{form.height_name}}</div>

<div class="item-icon" :class="[currentName == 'height' ? 'item-icon-active':'']"></div>

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">体重</div>

<div class="item-content flex" ref='weight' @click="openSelect('weight',weightList)">

<div class="item-check-title">{{form.weight_name}}</div>

<div class="item-icon" :class="[currentName == 'weight' ? 'item-icon-active':'']"></div>

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">标签<span class="sex-tip">(可多选)</span></div>

<div class="item-content flex" ref='label' @click="openSelect('label',labelList)">

<div class="item-check-title">{{form.label_name}}</div>

<div class="item-icon" :class="[currentName == 'label' ? 'item-icon-active':'']"></div>

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">星座<span class="sex-tip">(不可修改)</span></div>

<!-- <div class="item-content flex" ref='constellation' @click="openSelect('constellation',constellationList)">

<div class="item-check-title">{{ form.constellation_name}}</div>

<div class="item-icon" :class="[currentName == 'constellation' ? 'item-icon-active':'']"></div>

</div> -->

<div class="item-content flex" ref='constellation'>

<div class="item-check-title">{{ form.constellation_name}}</div>

<div class="item-icon"></div>

</div>

</div>

<!--  -->

</div>

<!--  -->

<!--  -->

<!--  -->

<div class="list-layout">

<div class="title-box">

交友信息

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">职业</div>

<div class="item-content flex" ref='occupation' @click="openSelect('occupation',occupationList)">

<div class="item-check-title">{{form.occupation_name}}</div>

<div class="item-icon" :class="[currentName == 'occupation' ? 'item-icon-active':'']"></div>

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">所在地</div>

<div class="item-content flex" ref='province' @click="openSelect('province',provinceList)">

<div class="item-check-title">{{ form.province_name }}</div>

<div class="item-icon" :class="[currentName == 'province' ? 'item-icon-active':'']"></div>

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">手机号</div>

<div class="item-content flex">

<!-- <input type="tel" novalidate="novalidate" pattern="[0-9]*" placeholder="未填写"

                            v-model="form.mobile"> -->

<input type="tel" pattern="[0-9]*" maxlength="11" placeholder="11位手机号" v-model="form.mobile">

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">个性签名</div>

<div class="item-content flex">

<input type="text" placeholder="个性签名" v-model="form.bio">

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">自我介绍</div>

<div class="item-content flex">

<input type="text" placeholder="自我介绍" v-model="form.introduce_oneself">

</div>

</div>

<!--  -->

</div>

<!--  -->

<!--  -->

<!--  -->

<div class="list-layout">

<div class="title-box">

情感

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">感情状况</div>

<div class="item-content flex" ref='feel' @click="openSelect('feel',feelList)">

<div class="item-check-title">{{form.feel_name}}</div>

<div class="item-icon" :class="[currentName == 'feel' ? 'item-icon-active':'']"></div>

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">对爱情的看法</div>

<div class="item-content flex">

<input type="text" placeholder="未填写" v-model="form.love_view" @focus="">

</div>

</div>

<!--  -->

<div class="list-item-box flex">

<div class="item-title">对另一半的看法</div>

<div class="item-content flex">

<input type="text" placeholder="未填写" v-model="form.partner_view">

</div>

</div>

<!--  -->

</div>

<!--  -->

<!--  -->

<!--  -->

<div class="submit-box">

<div class="go-submit" @click="preserveUser">

保存

</div>

</div>

</form>

<!--  -->

<div class="container">

</div>

</div>

<script src="./js/public.js"></script>

<script src="./js/vue.js"></script>

<script src="./js/iosSelect.js"></script>

<!-- <script src="./js/datePicker.js"></script> -->

<script>

let app = new Vue({

el: '#app',

data: {

form: {

avatar: '',

live_image: '',

chat_image: '',

nickname: '',

birthday: '',

genderlist: 0, //性别

province: '', //省份id,

province_name: '',

city: '', //城市id

city_name: '',

feelinglist: '', //感情状况

love_view: '',

partner_view: '',

introduce_oneself: '',

height_id: '', //身高id

height_name: '',

weight_id: '', //体重id

weight_name: '',

constellation_id: '', //星座id

constellation_name: '',

occupation_id: '', //职业id

occupation_name: '',

label_id: [], //标签id

label_name: '',

bio: '',

mobile: '',

feelinglist: '',

feel_name: '',

feel_id: '',

},

heigthList: [],

weightList: [],

occupationList: [],

labelList: [],

constellationList: [],

provinceList: [],

cityList: [],

feelList: [{

id: 1,

name: '未婚',

value: '未婚',

},

{

id: 2,

name: '单身',

value: '单身',

},

{

id: 3,

name: '已婚',

value: '已婚',

},

],

labelID: [],

// provinceName: '',

// cityNname: '',

// feelNmae: '',

// heightName: '',

// weightName: '',

// constellationNmae: '',

// occupationName: '',

// labelName: '',

option: [],

showSelect: false,

optionIndex: 0,

currentName: '',

provinceNext: true,

uploadName: '',

avatarUrl: '',

live_imageUrl: '',

chat_imageUrl: '',

token: 'e278a88e-ef92-4d98-9828-87fe78e8fa64',

baseUrl: 'https://qingmeizb.heifeng.xin',

},

created() {

const that = this

getUserToken().then((response) => {

that.token = response

})

},

mounted() {

/**/

this.getUser()

/**/

this.getHeight()

this.getWeight()

this.getOccupation()

/**/

//this.getLabel()

this.getConstellation()

this.getProvince()

},

watch: {

token: function() {

this.getUser()

}

},

methods: {

//

getUser() {

const that = this

setajax({

url: '/index.php/api/Personal/get_personal',

headers: {

token: that.token

},

success: function(res) {

let labelid = res.data.label_id

let feel = res.data.feelinglist

let feelNmae = ''

that.avatarUrl = res.data.avatar

that.live_imageUrl = res.data.live_image

that.chat_imageUrl = res.data.chat_image

that.form = res.data

if (labelid.length) {

that.labelID = labelid.split(',')

console.log("0that.labelID",that.labelID)

that.getLabel()//等获取用户的标签列表后,在进行查询操作

}

if (feel == 1) {

feelNmae = '未婚'

} else if (feel == 2) {

feelNmae = '单身'

} else {

feelNmae = '已婚'

}

/*

let a = 0

//将数组内容结构成字符串

for (let i = 0; i < res.data.label.length; i++) {

if(a==0){

a = res.data.label[i].name

}else{

console.log("标签", res.data.label[i].name)

a = a + ',' + res.data.label[i].name

}

}

that.form.label_name  = a

console.log("a",a)

console.log("显示最终标签列表", that.form.label_name)*/

that.form.label_name = ''

that.form.feel_name = feelNmae

that.form.feel_id = feel

if (that.form.province_name == '') {

that.form.province_name = '请选择省'

}

if (that.form.city_name == '') {

that.form.city_name = '请选择市'

}

that.form.province_name = that.form.province_name + '  ' + that.form.city_name

}

})

},

// 身高

getHeight() {

const that = this

setajax({

url: '/index.php/api/Personal/height_list',

success: function(res) {

let list = res.data

list.forEach((item, index) => {

item.checkStatus = false

item.value = item.name

})

that.heigthList = list

}

})

},

// 体重

getWeight() {

const that = this

setajax({

url: '/index.php/api/Personal/weight_list',

success: function(res) {

let list = res.data

list.forEach((item, index) => {

item.checkStatus = false

item.value = item.name

})

that.weightList = list

}

})

},

// 职业

getOccupation() {

const that = this

setajax({

url: '/index.php/api/Personal/occupation_list',

success: function(res) {

let list = res.data

list.forEach((item, index) => {

item.checkStatus = false

item.value = item.name

})

that.occupationList = list

}

})

},

//标签

getLabel() {

const that = this

setajax({

url: '/index.php/api/Personal/label_list',

success: function(res) {

let list = res.data

console.log("1list", list)

list.forEach((item, index) => {

/**/

item.checkStatus = false

item.value = item.name

})

console.log("2list", list)

console.log("111that.labelID", that.labelID)

if (that.labelID.length > 0) {

let labname = ''

that.labelID.forEach((labitem, labidx) => {

console.log("labitem", labitem)

list.forEach((listitem, listidx) => {

console.log("listitem", listitem)

console.log("labitem", labitem)

if (labitem == listitem.id) {

listitem.checkStatus = true

labname = labname == '' ? listitem.name : '' + labname + ',' + listitem.name + ''

}

})

})

that.form.label_name = labname

}

that.labelList = list

that.$forceUpdate()

}

})

},

//星座

getConstellation() {

const that = this

setajax({

url: '/index.php/api/Personal/constellation_list',

success: function(res) {

let list = res.data

list.forEach((item, index) => {

item.checkStatus = false

item.value = item.name

})

that.constellationList = list

}

})

},

// 地址

getProvince() {

const that = this

setajax({

url: '/index.php/api/index/region',

data: {

parent_id: 0

},

success: function(res) {

let list = res.data

list.forEach((item, index) => {

item.checkStatus = false

item.value = item.name

})

that.provinceList = list

that.getCity(list[0].id)

}

})

},

//二级城市

getCity(id) {

const that = this

setajax({

url: '/index.php/api/index/region',

data: {

parent_id: id,

type: 1

},

success: function(res) {

let list = res.data

list.forEach((item, index) => {

item.checkStatus = false

item.value = item.name

})

that.cityList = list

console.log(that.cityList.splice(that.cityList.length - 4, that.cityList.length - 1))

}

})

},

//

handfile(name) {

const that = this

let upfiles = that.$refs.imgfile

that.uploadName = name

upfiles.value = ''

upfiles.click()

},

//

upfile(e) {

const that = this

let files = that.$refs.imgfile

let form = new FormData()

form.append('file', files.files[0])

upajax({

data: form,

cache: false,

processData: false,

contentType: false,

success: function(res) {

console.log(res)

if (that.uploadName == "avatar") {

that.form.avatar = res.data.url

that.avatarUrl = res.data.url

} else if (that.uploadName == "live_image") {

that.form.live_image = res.data.url

that.live_imageUrl = res.data.url

} else if (that.uploadName == "chat_image") {

that.form.chat_image = res.data.url

that.chat_imageUrl = res.data.url

}

}

})

},

//

openSelect(name, list) {

const that = this

let titleName = {

height: '选择身高',

weight: '选择体重',

label: '选择标签',

constellation: '选择星座',

occupation: '选择职业',

province: '选择地区',

feel: '选择感情状况'

}

let thisName = name

let num = 1,

arr = [],

options = {

container: '.container',

title: titleName[thisName],

itemHeight: 50,

itemShowCount: 5,

showAnimate: true,

showLoading: true,

addClassName: 'iosSelectStyle',

};

if (name == 'label') {

num = 1

arr = [list]

options.callback = function(select) {

console.log(select)

if (select.checkstatus == 'true') {

that.labelID = that.labelID.filter(item => {

return item != select.id

})

console.log(that.labelID)

//

that.labelList.forEach((item, index) => {

if (item.id == select.id) {

item.checkStatus = false

}

})

console.log(that.labelList)

//

let labname = that.form.label_name.split(',')

labname = labname.filter(item => {

return item != select.name

})

that.form.label_name = labname.join()

} else {

that.labelID.push(select.id)

that.labelList.forEach((item, index) => {

if (item.id == select.id) {

item.checkStatus = true

}

})

that.form.label_name = that.form.label_name == '' ? select.name : '' + that.form.label_name + ',' + select.name +

''

}

that.$forceUpdate()

}

that.createSelect(num, arr, options)

} else if (name == 'province') {

num = 2

arr = [list, that.cityList]

options.relation = [1, 1]

options.oneLevelId = that.form.province

options.twoLevelId = that.form.city

options.callback = function(select, selectCity) {

console.log(select, selectCity)

let name = select.name

that.form.province = select.id

if (selectCity.name) {

name = name + '  ' + selectCity.name

that.form.city_name = selectCity.name

}

if (selectCity.id) {

that.form.city = selectCity.id

}

that.form.province_name = name

}

that.createSelect(num, arr, options)

} else {

let oneID = '' + thisName + '_id'

num = 1

arr = [list]

options.oneLevelId = that.form[oneID]

options.callback = function(select) {

console.log(select)

let name = '' + thisName + '_name'

// let id = '' + thisName + '_id'

that.form[name] = select.name

that.form[oneID] = select.id

that.$forceUpdate()

}

that.createSelect(num, arr, options)

}

},

createSelect(num, arr, options) {

const that = this

let selectShow = new IosSelect(num, [...arr], options)

},

//

preserveUser() {

const that = this

let form = that.form

let data = {

avatar: form.avatar,

live_image: form.live_image,

chat_image: form.chat_image,

nickname: form.nickname,

province: form.province,

city: form.city,

feelinglist: form.feel_id,

love_view: form.love_view,

partner_view: form.partner_view,

introduce_oneself: form.introduce_oneself,

height_id: form.height_id,

weight_id: form.weight_id,

constellation_id: form.constellation_id,

occupation_id: form.occupation_id,

bio: form.bio,

mobile: form.mobile

}

let label_id = that.labelID.join()

data.label_id = label_id

setajax({

url: '/index.php/api/Personal/sub_personal',

headers: {

token: that.token

},

data: data,

success: function(res) {

showTip(meg = "保存成功")

let setData = {

status: true

}

setTimeout(function() {

getbridge('wPageBack', setData, function() {})

}, 2000)

}

})

}

}

})

</script>

</body>

</html>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,802评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,109评论 2 379
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,683评论 0 335
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,458评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,452评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,505评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,901评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,550评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,763评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,556评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,629评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,330评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,898评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,897评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,140评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,807评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,339评论 2 342