7.10 增加登录页面,事件详情接口对接,我的点赞,关注收藏页面搭建,接口对接
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../common/vendor.js");
|
||||
const request_api = require("../../../request/api.js");
|
||||
const common_assets = require("../../../common/assets.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return {
|
||||
avatarTop: "",
|
||||
contentTop: "",
|
||||
avatar: "",
|
||||
//选择头像临时地址
|
||||
avatarUrl: "",
|
||||
//已上传的链接
|
||||
investPreferenceList: ["长期投资", "中短期投资", "风险控制型"],
|
||||
selectInvestIndex: -1,
|
||||
stockYearList: ["新手入门", "1年以内", "1-3年", "3-5年", "5-10年", "10年以上"],
|
||||
@@ -20,8 +25,16 @@ const _sfc_main = {
|
||||
onLoad() {
|
||||
this.avatarTop = common_vendor.inject("navHeight") + 60 / 750 * common_vendor.inject("windowWidth");
|
||||
this.contentTop = this.avatarTop + 75 / 750 * common_vendor.inject("windowWidth");
|
||||
this.getUserInfoData();
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 点击选择头像
|
||||
* @param {Object} e
|
||||
*/
|
||||
chooseAvatar(e) {
|
||||
this.avatar = e.detail.avatarUrl;
|
||||
},
|
||||
/**
|
||||
* 点击选择投资偏好
|
||||
* @param {Object} index
|
||||
@@ -64,6 +77,129 @@ const _sfc_main = {
|
||||
*/
|
||||
clickMarketItem(index) {
|
||||
this.preferredMarketList[index].select = !this.preferredMarketList[index].select;
|
||||
},
|
||||
/**
|
||||
* 点击上一步
|
||||
*/
|
||||
clickPre() {
|
||||
common_vendor.index.navigateBack();
|
||||
},
|
||||
/**
|
||||
* 点击完成
|
||||
*/
|
||||
clickFinish() {
|
||||
if (this.selectInvestIndex < 0) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请选择投资偏好",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.selectYearIndex < 0) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请选择炒股年限",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.selectRiskIndex < 0) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请选择风险偏好",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.selectScaleIndex < 0) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请选择投资规模",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
let arr2 = [];
|
||||
for (let item of this.preferredMarketList) {
|
||||
if (item.select) {
|
||||
arr2.push(item.title);
|
||||
}
|
||||
}
|
||||
if (arr2.length == 0) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请选择偏好市场",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.avatar) {
|
||||
let param = { avatar: this.avatar, isFile: 1 };
|
||||
updateBasicInfo(param).then((res) => {
|
||||
this.uploadInvestPreferenceData();
|
||||
}).catch((error) => {
|
||||
});
|
||||
} else
|
||||
this.uploadInvestPreferenceData();
|
||||
},
|
||||
/**
|
||||
* 更新投资偏好设置
|
||||
*/
|
||||
uploadInvestPreferenceData() {
|
||||
let param = {
|
||||
trading_experience: this.selectYearIndex,
|
||||
investment_style: this.investPreferenceList[this.selectInvestIndex],
|
||||
risk_preference: this.riskPreferenceList[this.selectRiskIndex],
|
||||
investment_amount: this.investmentScaleList[this.selectScaleIndex],
|
||||
preferred_markets: arr
|
||||
};
|
||||
request_api.updateInvestPreference(param).then((res) => {
|
||||
common_vendor.index.navigateBack({
|
||||
delta: 2
|
||||
});
|
||||
}).catch((error) => {
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取用户偏好设置数据
|
||||
*/
|
||||
getUserInfoData() {
|
||||
request_api.userInfo().then((res) => {
|
||||
if (res.code == 200) {
|
||||
let data = res.data.investment_preferences;
|
||||
for (var i = 0; i < this.investPreferenceList.length; i++) {
|
||||
let item = this.investPreferenceList[i];
|
||||
if (item == data.investment_style) {
|
||||
this.selectInvestIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.selectYearIndex = data.trading_experience;
|
||||
for (var i = 0; i < this.riskPreferenceList.length; i++) {
|
||||
let item = this.riskPreferenceList[i];
|
||||
if (item == data.risk_preference) {
|
||||
this.selectRiskIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < this.investmentScaleList.length; i++) {
|
||||
let item = this.investmentScaleList[i];
|
||||
if (item == data.investment_amount) {
|
||||
this.selectScaleIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (let item of this.preferredMarketList) {
|
||||
let arr2 = JSON.parse(data.preferred_markets);
|
||||
let arr1 = arr2[0].split(",");
|
||||
if (arr1.indexOf(item.title) > -1) {
|
||||
item.select = true;
|
||||
} else {
|
||||
item.select = false;
|
||||
}
|
||||
}
|
||||
} else
|
||||
common_vendor.wx$1.showToast({
|
||||
title: res.message
|
||||
});
|
||||
}).catch((error) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -81,9 +217,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
leftText: "信息完善"
|
||||
}),
|
||||
b: common_assets._imports_0,
|
||||
c: common_assets._imports_1$3,
|
||||
d: common_vendor.s("top:" + $data.avatarTop + "px;"),
|
||||
e: common_vendor.f($data.investPreferenceList, (item, index, i0) => {
|
||||
c: $data.avatar ? $data.avatar : $data.avatarUrl,
|
||||
d: common_assets._imports_1$3,
|
||||
e: common_vendor.o((...args) => $options.chooseAvatar && $options.chooseAvatar(...args)),
|
||||
f: common_vendor.s("top:" + $data.avatarTop + "px;"),
|
||||
g: common_vendor.f($data.investPreferenceList, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item),
|
||||
b: common_vendor.n("item " + ($data.selectInvestIndex == index ? "select" : "")),
|
||||
@@ -91,7 +229,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
d: common_vendor.o(($event) => $options.clickInvestItem(index), index)
|
||||
};
|
||||
}),
|
||||
f: common_vendor.f($data.stockYearList, (item, index, i0) => {
|
||||
h: common_vendor.f($data.stockYearList, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item),
|
||||
b: common_vendor.n("item " + ($data.selectYearIndex == index ? "select" : "")),
|
||||
@@ -99,7 +237,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
d: common_vendor.o(($event) => $options.clickYearItem(index), index)
|
||||
};
|
||||
}),
|
||||
g: common_vendor.f($data.riskPreferenceList, (item, index, i0) => {
|
||||
i: common_vendor.f($data.riskPreferenceList, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item),
|
||||
b: common_vendor.n("item " + ($data.selectRiskIndex == index ? "select" : "")),
|
||||
@@ -107,7 +245,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
d: common_vendor.o(($event) => $options.clickRiskItem(index), index)
|
||||
};
|
||||
}),
|
||||
h: common_vendor.f($data.investmentScaleList, (item, index, i0) => {
|
||||
j: common_vendor.f($data.investmentScaleList, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item),
|
||||
b: common_vendor.n("item " + ($data.selectScaleIndex == index ? "select" : "")),
|
||||
@@ -115,7 +253,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
d: common_vendor.o(($event) => $options.clickScaleItem(index), index)
|
||||
};
|
||||
}),
|
||||
i: common_vendor.f($data.preferredMarketList, (item, index, i0) => {
|
||||
k: common_vendor.f($data.preferredMarketList, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item.title),
|
||||
b: common_vendor.n("item " + (item.select ? "select" : "")),
|
||||
@@ -123,7 +261,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
d: common_vendor.o(($event) => $options.clickMarketItem(index), index)
|
||||
};
|
||||
}),
|
||||
j: common_vendor.s("top:" + $data.contentTop + "px;")
|
||||
l: common_vendor.s("top:" + $data.contentTop + "px;"),
|
||||
m: common_vendor.o(($event) => $options.clickPre()),
|
||||
n: common_vendor.o(($event) => $options.clickFinish())
|
||||
};
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view><nav-bar wx:if="{{a}}" u-i="ea3a6ff8-0" bind:__l="__l" u-p="{{a}}"></nav-bar><image class="topBg absolute" src="{{b}}" mode="widthFix"></image><view class="avatarC fixed" style="{{d}}"><image class="avatar" src="{{''}}" mode="aspectFill"></image><image class="icon absolute" src="{{c}}" mode="widthFix"></image></view><view class="preferenceC fixed" style="{{j}}"><view class="title">投资偏好设置</view><view class="section first">投资偏好</view><view class="list flexWrap"><view wx:for="{{e}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view><view class="section">炒股年限</view><view class="list flexWrap"><view wx:for="{{f}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view><view class="section">风险偏好</view><view class="list flexWrap"><view wx:for="{{g}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view><view class="section">投资规模</view><view class="list flexWrap"><view wx:for="{{h}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view><view class="section">偏好市场(可多选)</view><view class="list flexWrap"><view wx:for="{{i}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view></view><view class="bottomC fixed flex"><view class="pre btn">上一步</view><view class="finish btn flex1">完成</view></view></view>
|
||||
<view><nav-bar wx:if="{{a}}" u-i="ea3a6ff8-0" bind:__l="__l" u-p="{{a}}"></nav-bar><image class="topBg absolute" src="{{b}}" mode="widthFix"></image><view class="avatarC fixed" style="{{f}}"><image class="avatar" src="{{c}}" mode="aspectFill"></image><image class="icon absolute" src="{{d}}" mode="widthFix"></image><button class="absolute" open-type="chooseAvatar" bindchooseavatar="{{e}}"></button></view><view class="preferenceC fixed" style="{{l}}"><view class="title">投资偏好设置</view><view class="section first">投资偏好</view><view class="list flexWrap"><view wx:for="{{g}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view><view class="section">炒股年限</view><view class="list flexWrap"><view wx:for="{{h}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view><view class="section">风险偏好</view><view class="list flexWrap"><view wx:for="{{i}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view><view class="section">投资规模</view><view class="list flexWrap"><view wx:for="{{j}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view><view class="section">偏好市场(可多选)</view><view class="list flexWrap"><view wx:for="{{k}}" wx:for-item="item" wx:key="c" class="{{item.b}}" bindtap="{{item.d}}">{{item.a}}</view></view></view><view class="bottomC fixed flex"><view class="pre btn" bindtap="{{m}}">上一步</view><view class="finish btn flex1" bindtap="{{n}}">完成</view></view></view>
|
||||
@@ -11,7 +11,6 @@
|
||||
z-index: 10;
|
||||
}
|
||||
.avatarC .avatar {
|
||||
background-color: red;
|
||||
width: 100%;
|
||||
height: 150rpx;
|
||||
border-radius: 50%;
|
||||
@@ -23,6 +22,12 @@
|
||||
width: 40rpx;
|
||||
height: auto;
|
||||
}
|
||||
.avatarC button {
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.preferenceC {
|
||||
background-color: white;
|
||||
left: 0;
|
||||
|
||||
Reference in New Issue
Block a user