Commit 3e1330a2 authored by tao.huang's avatar tao.huang

feat: 表单联调

parent 5cbb97a3
...@@ -7,10 +7,16 @@ const { api } = requestModule; ...@@ -7,10 +7,16 @@ const { api } = requestModule;
* @returns * @returns
*/ */
export const uploadImage = (file64) => export const uploadImage = (file64) =>
api.post("/c/upload/image", { api.post(
img64: file64, "/c/upload/image",
}, { {
headers: { img64: file64,
"Content-Type": "application/json" },
} {
}); headers: {
"Content-Type": "application/json",
},
}
);
export const getHealthField = () => api.get("/c/user/getHealthField");
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
export default { export default {
data() { data() {
return { return {
curTabIndex: 3, curTabIndex: 0,
}; };
}, },
onLoad() {}, onLoad() {},
......
...@@ -35,7 +35,10 @@ ...@@ -35,7 +35,10 @@
open-type="chooseAvatar" open-type="chooseAvatar"
@chooseavatar="onChooseAvatar" @chooseavatar="onChooseAvatar"
> >
<image class="person-avatar-img" :src="formData.babyAvatar"></image> <image
class="person-avatar-img"
:src="formData.babyAvatar || $baseUrl + 'common/default_avatar.png'"
></image>
</button> </button>
</view> </view>
...@@ -96,7 +99,11 @@ ...@@ -96,7 +99,11 @@
v-else-if="item.type === 'picker'" v-else-if="item.type === 'picker'"
:mode="item.mode" :mode="item.mode"
:range="item.range" :range="item.range"
:value="item.mode === 'date' ? formData[item.name] : getPickerIndex(item)" :value="
item.mode === 'date'
? formData[item.name]
: getPickerIndex(item)
"
:onPickerChange="(e) => onPickerChange(e, item.name)" :onPickerChange="(e) => onPickerChange(e, item.name)"
:onLayerVisibleChange="(e) => (pageStatus.btnStatus = !e)" :onLayerVisibleChange="(e) => (pageStatus.btnStatus = !e)"
:onStatusChange="onDateStatusChange" :onStatusChange="onDateStatusChange"
...@@ -195,7 +202,7 @@ ...@@ -195,7 +202,7 @@
</template> </template>
<script setup> <script setup>
import { ref, watch, onMounted } from "vue"; import { ref, watch, onMounted, computed } from "vue";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import { useUserStore } from "../../stores/user.js"; import { useUserStore } from "../../stores/user.js";
import PickerCustom from "../../components/PickerCustom.vue"; import PickerCustom from "../../components/PickerCustom.vue";
...@@ -203,6 +210,7 @@ import MultiSelectLayer from "../../components/MultiSelectLayer.vue"; ...@@ -203,6 +210,7 @@ import MultiSelectLayer from "../../components/MultiSelectLayer.vue";
import { uploadImage } from "../../api/common.js"; import { uploadImage } from "../../api/common.js";
import { showLoading, hideLoading } from "../../utils/index.js"; import { showLoading, hideLoading } from "../../utils/index.js";
import { updateBabyInfo, getGestationalWeeks } from "../../api/user.js"; import { updateBabyInfo, getGestationalWeeks } from "../../api/user.js";
import { usePageCfgStore } from "../../stores/pageCfg";
const userStore = useUserStore(); const userStore = useUserStore();
const pageType = ref("add"); const pageType = ref("add");
...@@ -283,29 +291,15 @@ watch( ...@@ -283,29 +291,15 @@ watch(
} }
); );
const contentLikeOptions = [ const pageCfgStore = usePageCfgStore();
"奶粉选择",
"奶粉成分", // 直接取store中的配置项(非响应式),后续store变化不会自动更新
"奶粉冲泡", const contentLikeOptions = pageCfgStore.conetntCfg.contentLikeOptions;
"宝宝奶量", const productLikeOptions = pageCfgStore.conetntCfg.productLikeOptions;
"生长发育", const specialAttentionOptions = pageCfgStore.conetntCfg.specialAttentionOptions;
"常见疾病", const channelOptions = pageCfgStore.conetntCfg.channelOptions;
"体检疫苗",
"饮食营养补充", console.log("contentLikeOptions", contentLikeOptions);
"辅食营养",
"亲子关系",
"早教游戏",
];
const productLikeOptions = [
"飞鹤星飞帆",
"星飞帆卓睿",
"星飞帆卓耀",
"星飞帆卓初",
"星飞帆臻稚卓蓓",
"星飞帆淳芮有机",
];
const specialAttentionOptions = ["过敏", "长肉", "肠道", "消化", "脑发育"];
const channelOptions = ["电商(京东/天猫)", "母婴店"];
const formItems = [ const formItems = [
{ {
...@@ -522,8 +516,8 @@ const onSubmit = async (e) => { ...@@ -522,8 +516,8 @@ const onSubmit = async (e) => {
} }
// 移除空值属性 // 移除空值属性
Object.keys(data).forEach(key => { Object.keys(data).forEach((key) => {
if (data[key] === '') { if (data[key] === "") {
delete data[key]; delete data[key];
} }
}); });
...@@ -584,7 +578,8 @@ const handleUploadBackground = async (e) => { ...@@ -584,7 +578,8 @@ const handleUploadBackground = async (e) => {
success: async (res) => { success: async (res) => {
const tempFilePath = res.tempFilePaths[0]; const tempFilePath = res.tempFilePaths[0];
const fs = uni.getFileSystemManager(); const fs = uni.getFileSystemManager();
const base64 = "data:image/jpeg;base64," + fs.readFileSync(tempFilePath, "base64"); const base64 =
"data:image/jpeg;base64," + fs.readFileSync(tempFilePath, "base64");
showLoading(); showLoading();
const uploadRes = await uploadImage(base64); const uploadRes = await uploadImage(base64);
......
import { defineStore } from 'pinia';
export const useCounterStore = defineStore('counter', {
state: () => {
return { count: 0 };
},
// 也可以这样定义
// state: () => ({ count: 0 })
actions: {
increment() {
console.log(this.count);
this.count++;
},
},
});
\ No newline at end of file
import { defineStore } from "pinia";
import { JumpType } from "@/utils";
import { WHEEL_OPTIONS_YL, WHEEL_OPTIONS_YZ } from "@/cfg";
export const usePageCfgStore = defineStore("pageCfg", {
state: () => {
return {
toolList: [
{
icon: "my/literature.png",
title: "育儿百科",
url: "https://secret.feihe.com/secret.html",
jumpType: JumpType.H5,
},
{
icon: "my/suyuan.png",
title: "产品溯源",
url: "",
jumpType: JumpType.H5,
},
{
icon: "my/book.png",
title: "奶娃宝典",
url: "",
jumpType: JumpType.INNER,
},
{
icon: "my/doctor.png",
title: "医生问诊",
url: "",
jumpType: JumpType.MINI,
checkRegister: true,
},
{
icon: "my/babytest.png",
title: "宝宝体质测试",
url: "",
jumpType: JumpType.H5,
},
],
conetntCfg: {
wheelOptionsYL: WHEEL_OPTIONS_YL || [],
wheelOptionsYZ: WHEEL_OPTIONS_YZ || [],
contentLikeOptions: [
"奶粉选择",
"奶粉成分",
"奶粉冲泡",
"宝宝奶量",
"生长发育",
"常见疾病",
"体检疫苗",
"饮食营养补充",
"辅食营养",
"亲子关系",
"早教游戏",
],
productLikeOptions: [
"飞鹤星飞帆",
"星飞帆卓睿",
"星飞帆卓耀",
"星飞帆卓初",
"星飞帆臻稚卓蓓",
"星飞帆淳芮有机",
],
specialAttentionOptions: ["过敏", "长肉", "肠道", "消化", "脑发育"],
channelOptions: ["电商(京东/天猫)", "母婴店"],
},
};
},
actions: {
/**
* 设置用户cuk
* @param {Object} cuk
*/
setCuk(cuk) {
this.cuk = cuk;
uni.setStorageSync("cuk", cuk);
},
},
});
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
<image <image
class="avatar" class="avatar"
:src=" :src="
babyInfo?.content?.babyAvatar || $baseUrl + 'common/default_avatar.png' babyInfo?.content?.babyAvatar ||
$baseUrl + 'common/default_avatar.png'
" "
mode="aspectFill" mode="aspectFill"
/> />
...@@ -119,8 +120,24 @@ ...@@ -119,8 +120,24 @@
<view class="tool-container"> <view class="tool-container">
<text class="tool-title"> 工具 </text> <text class="tool-title"> 工具 </text>
<view class="tool-list"> <view class="tool-list">
<view class="tool-item" v-for="item in toolList" :key="item.title"> <view
<image class="tool-icon" :src="item.icon" mode="aspectFit" /> class="tool-item"
v-for="item in toolList"
:key="item.title"
@click="handleToolClick(item)"
>
<image
class="tool-icon"
:src="$baseUrl + item.icon"
mode="aspectFit"
/>
<button
v-if="item.checkRegister && !cfgStatus.isRegister"
class="tool-btn-register"
type="primary"
open-type="getPhoneNumber"
@getphonenumber="getRealtimePhoneNumber"
/>
</view> </view>
</view> </view>
</view> </view>
...@@ -140,13 +157,15 @@ import { ref, onMounted, getCurrentInstance, computed, watch } from "vue"; ...@@ -140,13 +157,15 @@ import { ref, onMounted, getCurrentInstance, computed, watch } from "vue";
import RegisterLayer from "../components/RegisterLayer.vue"; import RegisterLayer from "../components/RegisterLayer.vue";
import BabySwitcher from "../components/BabySwitcher.vue"; import BabySwitcher from "../components/BabySwitcher.vue";
import WheelSelector from "../components/WheelSelector.vue"; import WheelSelector from "../components/WheelSelector.vue";
import { WHEEL_OPTIONS_YL, WHEEL_OPTIONS_YZ } from "@/cfg";
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import { throttleTap } from "@/utils"; import { usePageCfgStore } from "@/stores/pageCfg";
import { jump, JumpType } from "@/utils";
import { getHealthField } from "@/api/common";
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const $baseUrl = proxy.$baseUrl; const $baseUrl = proxy.$baseUrl;
const userStore = useUserStore(); const userStore = useUserStore();
const pageCfgStore = usePageCfgStore();
const cfgStatus = ref({ const cfgStatus = ref({
openBabyCardDesc: false, openBabyCardDesc: false,
...@@ -157,33 +176,7 @@ const cfgStatus = ref({ ...@@ -157,33 +176,7 @@ const cfgStatus = ref({
const wheelOptions = ref([]); const wheelOptions = ref([]);
const wheelSelectedIndex = ref(0); const wheelSelectedIndex = ref(0);
const toolList = ref([ const toolList = computed(() => pageCfgStore?.toolList);
{
icon: $baseUrl + "my/code.png",
title: "扫码积分",
url: "",
},
{
icon: $baseUrl + "my/suyuan.png",
title: "产品溯源",
url: "",
},
{
icon: $baseUrl + "my/book.png",
title: "奶娃宝典",
url: "",
},
{
icon: $baseUrl + "my/doctor.png",
title: "医生问诊",
url: "",
},
{
icon: $baseUrl + "my/literature.png",
title: "育儿百科",
url: "",
},
]);
const babyInfo = computed(() => userStore?.babyInfo || {}); const babyInfo = computed(() => userStore?.babyInfo || {});
...@@ -217,6 +210,40 @@ const navigateTo = (url) => { ...@@ -217,6 +210,40 @@ const navigateTo = (url) => {
}); });
}; };
const handleToolClick = async (item) => {
if (item.title === "医生问诊") {
const res = await getHealthField();
if (!res.success) {
uni.showToast({
title: "获取健康字段失败",
icon: "none",
});
return;
}
const { sign, timestamp, appId, partnerUserId } = res.data;
jump({
type: JumpType.MINI,
url: "/pages/partner/redirect",
extra: {
appId: "wx81ecfb5aa3fb512f",
extraData: {
sign, // 参考 4.请求参数
timestamp, // 参考 4.请求参数
appId, // 参考 4.请求参数
partnerUserId, // 参考 4.请求参数
targetApp:
"/h5/partner/shining-like-a-start/landing-free-consult?sysType=CRF",
},
},
});
} else {
jump({ type: item.jumpType, url: item.url });
}
};
// 编辑个人资料 // 编辑个人资料
const handleEditProfile = () => { const handleEditProfile = () => {
if (!userStore.userInfo || JSON.stringify(userStore.userInfo) === "{}") { if (!userStore.userInfo || JSON.stringify(userStore.userInfo) === "{}") {
...@@ -242,7 +269,10 @@ const onRegisterConfirm = (data) => { ...@@ -242,7 +269,10 @@ const onRegisterConfirm = (data) => {
// 获取用户信息 // 获取用户信息
const initData = async () => { const initData = async () => {
if (!userStore?.userInfo?.memberId || userStore?.userInfo?.memberId == "not_login") { if (
!userStore?.userInfo?.memberId ||
userStore?.userInfo?.memberId == "not_login"
) {
cfgStatus.value.isRegister = false; cfgStatus.value.isRegister = false;
cfgStatus.value.showDetail = false; cfgStatus.value.showDetail = false;
return; return;
...@@ -256,7 +286,9 @@ const initData = async () => { ...@@ -256,7 +286,9 @@ const initData = async () => {
if (__showDetail) { if (__showDetail) {
wheelOptions.value = wheelOptions.value =
babyInfo.value.babyStage == 2 ? WHEEL_OPTIONS_YL : WHEEL_OPTIONS_YZ; babyInfo.value.babyStage == 2
? pageCfgStore.conetntCfg.wheelOptionsYL
: pageCfgStore.conetntCfg.wheelOptionsYZ;
const index = wheelOptions.value.findIndex( const index = wheelOptions.value.findIndex(
(item) => item.label == babyInfo.value.babyAge (item) => item.label == babyInfo.value.babyAge
); );
...@@ -556,6 +588,8 @@ defineExpose({}); ...@@ -556,6 +588,8 @@ defineExpose({});
height: 152rpx; height: 152rpx;
margin-left: 26rpx; margin-left: 26rpx;
margin-bottom: 24rpx; margin-bottom: 24rpx;
position: relative;
.tool-icon { .tool-icon {
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -564,6 +598,15 @@ defineExpose({}); ...@@ -564,6 +598,15 @@ defineExpose({});
&:nth-child(4n + 1) { &:nth-child(4n + 1) {
margin-left: 0; margin-left: 0;
} }
.tool-btn-register {
position: absolute;
width: 152rpx;
height: 152rpx;
top: 0;
left: 0;
opacity: 0;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment