diff --git a/.env.development b/.env.development index 008f505..19ff852 100755 --- a/.env.development +++ b/.env.development @@ -1,15 +1,15 @@ -APP_BASE_URL=https://test.birkenstock.net.cn/api/h5app/wxapp -APP_WEBSOCKET=wss://test.birkenstock.net.cn/ws +APP_BASE_URL=http://47.103.169.154:8080/api/h5app/wxapp +APP_WEBSOCKET=wss://http://47.103.169.154:8080/ws APP_COMPANY_ID=1 APP_PLATFORM=standard -APP_CUSTOM_SERVER=https://test.birkenstock.net.cn/ +APP_CUSTOM_SERVER=http://47.103.169.154:8081/ APP_HOME_PAGE=/pages/index APP_TRACK=youshu APP_YOUSHU_TOKEN=bi281e87ab2424481a # APP_ID=wx3e1c17c88abf3e45 -APP_ID=wx72e9e1a93420862c +APP_ID=wx55ff808ba0e28b1d APP_MAP_KEY=1ccc1ebc947719886f0cd766d70241fe -APP_MAP_NAME=BIRKENSTOCK门店定位 +APP_MAP_NAME=oneX新零售门店定位 APP_IMAGE_CDN=https://b-img-cdn.yuanyuanke.cn/ecshopx-vshop APP_IMAGE_CDN_NEW=https://espier-oss-cdn.oss-cn-shanghai.aliyuncs.com/default_project/wxAssets APP_DIANWU_URL= diff --git a/.env.development.bak b/.env.development.ba similarity index 62% rename from .env.development.bak rename to .env.development.ba index 19ff852..008f505 100755 --- a/.env.development.bak +++ b/.env.development.ba @@ -1,15 +1,15 @@ -APP_BASE_URL=http://47.103.169.154:8080/api/h5app/wxapp -APP_WEBSOCKET=wss://http://47.103.169.154:8080/ws +APP_BASE_URL=https://test.birkenstock.net.cn/api/h5app/wxapp +APP_WEBSOCKET=wss://test.birkenstock.net.cn/ws APP_COMPANY_ID=1 APP_PLATFORM=standard -APP_CUSTOM_SERVER=http://47.103.169.154:8081/ +APP_CUSTOM_SERVER=https://test.birkenstock.net.cn/ APP_HOME_PAGE=/pages/index APP_TRACK=youshu APP_YOUSHU_TOKEN=bi281e87ab2424481a # APP_ID=wx3e1c17c88abf3e45 -APP_ID=wx55ff808ba0e28b1d +APP_ID=wx72e9e1a93420862c APP_MAP_KEY=1ccc1ebc947719886f0cd766d70241fe -APP_MAP_NAME=oneX新零售门店定位 +APP_MAP_NAME=BIRKENSTOCK门店定位 APP_IMAGE_CDN=https://b-img-cdn.yuanyuanke.cn/ecshopx-vshop APP_IMAGE_CDN_NEW=https://espier-oss-cdn.oss-cn-shanghai.aliyuncs.com/default_project/wxAssets APP_DIANWU_URL= diff --git a/.env.production b/.env.production index 008f505..133da8c 100755 --- a/.env.production +++ b/.env.production @@ -1,8 +1,8 @@ -APP_BASE_URL=https://test.birkenstock.net.cn/api/h5app/wxapp -APP_WEBSOCKET=wss://test.birkenstock.net.cn/ws +APP_BASE_URL=https://slb.birkenstock.net.cn/api/h5app/wxapp +APP_WEBSOCKET=wss://slb.birkenstock.net.cn/ws APP_COMPANY_ID=1 APP_PLATFORM=standard -APP_CUSTOM_SERVER=https://test.birkenstock.net.cn/ +APP_CUSTOM_SERVER=https://slb.birkenstock.net.cn/ APP_HOME_PAGE=/pages/index APP_TRACK=youshu APP_YOUSHU_TOKEN=bi281e87ab2424481a diff --git a/project.config.json b/project.config.json index 148f96e..36cad77 100755 --- a/project.config.json +++ b/project.config.json @@ -2,7 +2,7 @@ "miniprogramRoot": "dist/", "projectname": "ecshopx-vshop", "description": "weshop for platform", - "appid": "wx72e9e1a93420862c", + "appid": "wx55ff808ba0e28b1d", "setting": { "urlCheck": false, "es6": false, diff --git a/src/components/sp-page/index.js b/src/components/sp-page/index.js index e22e5de..739c492 100755 --- a/src/components/sp-page/index.js +++ b/src/components/sp-page/index.js @@ -304,7 +304,7 @@ function SpPage (props, ref) { // 'icon-home1': cusCurrentPage == 1, 'icon-fanhui': alwaysBackUrl ? true : cusCurrentPage != 1 })} - style={{ color: isBlack ? 'white' : 'black' }} + // style={{ color: isBlack ? 'white' : 'black' }} onClick={() => { if (alwaysBackUrl) { Taro.navigateTo({ diff --git a/src/pages/index.js b/src/pages/index.js index 560b280..8c80739 100755 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -574,6 +574,7 @@ function Home () { const indexUrl = 'https://mp.weixin.qq.com/s/LBXthKa-P9gNK8FCv3n1pA' const handleGoWx = () => { + return handleApply() Taro.navigateTo({ url: '/pages/webview?url=' + encodeURIComponent(indexUrl) }) } return ( diff --git a/src/pages/recommend/apply.js b/src/pages/recommend/apply.js index 2f54b0e..be049ae 100644 --- a/src/pages/recommend/apply.js +++ b/src/pages/recommend/apply.js @@ -24,12 +24,17 @@ const initState = { formData: {}, formList: [{}], areaList: [], + changci: {}, + formDataList: [], } export default function detail () { const $instance = getCurrentInstance() const [state, setState] = useImmer(initState) const { appName } = useSelector((_state) => _state.sys) const { userInfo = {} } = useSelector((_state) => _state.user) + const pages = getCurrentPages() + const current = pages[pages.length - 1] + const eventChannel = current.getOpenerEventChannel() const { isLogin } = useLogin({ autoLogin: true, }) @@ -50,8 +55,12 @@ export default function detail () { }) } const _item = recordList.list?.[0] || {} + const { content = [] } = activity_info.formdata + const formdata = content[0]?.formdata || [] setState(draft => { draft.isLoading = false + // draft.formList = formdata.sort((a, b) => a.id - b.id) + draft.formDataList = formdata draft.activeInfo = { ...activity_info, user_code, @@ -61,13 +70,18 @@ export default function detail () { status: _item.is_write_off === '1' ? 'done' : _item.status, isLoading: false } - draft.checked = !!_item + // draft.checked = !!_item }) } useEffect(() => { getActiveDetail() fetchAreaData() + eventChannel.on('apply', (res) => { + setState(draft => { + draft.changci = res + }) + }) }, []) useEffect(() => { @@ -77,12 +91,14 @@ export default function detail () { username: userInfo.username, mobile: userInfo.mobile, } + draft.formData['username'] = userInfo.username + draft.formData['mobile'] = userInfo.mobile }) } }, [userInfo, isLogin]) - const { isLoading, activeInfo = {}, visible, formInfo, checked, status, isShare, alwaysBackUrl, isSub, formData, formList, areaList } = state + const { isLoading, activeInfo = {}, visible, formInfo, checked, status, isShare, alwaysBackUrl, isSub, formData, formList, areaList, formDataList, changci } = state const handleConfirm = async () => { if (!isLogin || !userInfo) return @@ -104,12 +120,76 @@ export default function detail () { if (!res.confirm) return setState((draft) => { draft.checked = true - draft.visible = true + // draft.visible = true }) + } else { + const _formData = formDataList.map((d) => { + return { + ...d, + answer: formData[d.field_name] + } + }) + let flag = true + try { + _formData.forEach((d) => { + const { field_name, field_title, answer } = d + const reg = /^[1][3,4,5,7,8,9][0-9]{9}$/ + if ((formData['has_partner'] === '否' && field_name.includes('partner') || field_name.includes('city') || (field_name === 'mobile' && answer === userInfo.mobile))) { + return + } + if (field_name === 'mobile' || field_name === 'partner_mobile') { + if (!reg.test(answer)) { + Taro.showToast({ + title: `${formData['has_partner'] === '是' ? '同行人' : ''}${field_title}格式不正确`, + icon: 'none' + }) + throw new Error(`${field_title}格式不正确`) + } + } else { + if (!answer || !answer.trim()) { + Taro.showToast({ + title: `请填写${formData['has_partner'] === '是' ? '同行人' : ''}${field_title}`, + icon: 'none' + }) + throw new Error(`${formData['has_partner'] === '是' ? '同行人' : ''}${field_title}不能为空`) + } + } + }) + } catch (error) { + flag = false + } + if (!flag) return + const content = { + title: '', + sort: 1, + formdata: _formData + } + const { status } = await api.user.registrationSubmit({ + formdata: { content: JSON.stringify([content]) }, + activity_id: activeInfo.activity_id, + registration_session_id: changci.id + }) + if (status) { + const templeparams = { + temp_name: 'yykweishop', + source_type: 'activity' + } + const { template_id } = await api.user.newWxaMsgTmpl(templeparams) + Taro.requestSubscribeMessage({ + tmplIds: template_id, + success: () => { + }, + fail: (err) => { + }, + complete: () => { + Taro.navigateTo({ url: '/pages/recommend/status?success=true&id=' + activeInfo.activity_id }) + } + }) + } } - setState((draft) => { - draft.visible = true - }) + // setState((draft) => { + // draft.visible = true + // }) } const fetchAreaData = async () => { @@ -244,12 +324,11 @@ export default function detail () { }, 800) } - const pickerChange = (e) => { + const pickerChange = (e, key) => { const { value } = e.detail - console.log("🚀 ~ file: apply.js:247 ~ value:", value) - // setState((draft) => { - // draft.formData.sex = value - // }) + setState((draft) => { + draft.formData[key] = areaList[value]?.label + }) } const handleAddApply = (flag) => { if (formList.length > 2) { @@ -258,10 +337,12 @@ export default function detail () { if (flag) { setState((draft) => { draft.formList = [...formList, {}] + draft.formData['has_partner'] = '是' }) } else { setState((draft) => { draft.formList = [formList[0]] + draft.formData['has_partner'] = '否' }) } } @@ -269,19 +350,19 @@ export default function detail () { const formItem = activeInfo.formdata?.key_index || [] // !!activeInfo?.total_count ? <> : return ( - : renderFooter()} loading={isLoading} className='page-recommend-apply' alwaysBackUrl={alwaysBackUrl} isBlack> - 第一场 13:00-14:00 + : renderFooter()} loading={isLoading} className='page-recommend-apply' > + 第{changci.index}场 {changci.start}-{changci.end} 请填写您的个人信息 {formList.map((item, index) => 姓名 0 ? '他人' : ''}姓名`} - onInput={(e) => onIptChange(e, 'username')} + onInput={(e) => onIptChange(e, index === 0 ? 'username' : 'partner_name')} /> @@ -289,10 +370,11 @@ export default function detail () { 手机 0 ? '他人' : ''}手机号`} - onInput={(e) => onIptChange(e, 'mobile')} + onInput={(e) => onIptChange(e, index === 0 ? 'mobile' : 'partner_mobile')} /> @@ -300,13 +382,13 @@ export default function detail () { 性别 - - - + onIptChange({ detail: { value: '男' } }, index === 0 ? 'gender' : 'partner_gender')} style={{ paddingRight: '10rpx' }} > + + - + onIptChange({ detail: { value: '女' } }, index === 0 ? 'gender' : 'partner_gender')} > - + @@ -315,13 +397,13 @@ export default function detail () { 是否拥有BIRKENSTOCK鞋履 - + onIptChange({ detail: { value: '是' } }, index === 0 ? 'has_bought' : 'partner_has_bought')} style={{ paddingRight: '10rpx' }}> - + - + onIptChange({ detail: { value: '否' } }, index === 0 ? 'has_bought' : 'partner_has_bought')}> - + @@ -331,12 +413,12 @@ export default function detail () { 常驻城市(选填) pickerChange(e, index === 0 ? 'city_name' : 'partner_city_name')} range={areaList} rangeKey="label" > - 测试 + {formData[index === 0 ? 'city_name' : 'partner_city_name']} @@ -346,13 +428,13 @@ export default function detail () { 是否协同他人一起参加 - handleAddApply(1)} className="flex-row"> + handleAddApply(1)} className="flex-row" style={{ paddingRight: '10rpx' }}> - + handleAddApply(0)} className="flex-row"> - + diff --git a/src/pages/recommend/apply.scss b/src/pages/recommend/apply.scss index 077ead6..ae1dc20 100644 --- a/src/pages/recommend/apply.scss +++ b/src/pages/recommend/apply.scss @@ -46,7 +46,7 @@ color: #000; } .flex-row { - margin-left: 20rpx; + // margin-left: 20rpx; } } } diff --git a/src/pages/recommend/detail.js b/src/pages/recommend/detail.js index bd96c59..9d8c088 100644 --- a/src/pages/recommend/detail.js +++ b/src/pages/recommend/detail.js @@ -21,6 +21,8 @@ const initState = { isShare: false, alwaysBackUrl: "/pages/index", isSub: false, + changci: [], + applyStatus: false, } export default function detail () { const $instance = getCurrentInstance() @@ -36,8 +38,9 @@ export default function detail () { const getActiveDetail = async () => { const { id: activity_id, alwaysBackUrl } = $instance.router.params if (!activity_id) return - const { status, activity_info = {}, total_count, user_code, recordList = {} } = await api.user.registrationActivity({ activity_id }) - if (total_count > 0 && !alwaysBackUrl) { + const { status, changci = [], activity_info = {}, total_count, user_code, recordList = {} } = await api.user.registrationActivity({ activity_id }) + const _applyStatus = changci.some((item) => item.has_stauts == 1) + if (_applyStatus && !alwaysBackUrl) { Taro.redirectTo({ url: '/pages/recommend/status?&id=' + activity_id }) return } @@ -61,6 +64,9 @@ export default function detail () { isLoading: false } draft.checked = !!_item + // MM-DD + draft.changci = changci.map((item, index) => ({ index: index + 1, start: dayjs(item.start_time).format('HH:mm'), end: dayjs(item.end_time).format('HH:mm'), limit: item.join_limit, join: item.has_join_num, id: item.registration_session_id, activity_id: item.activity_id, has_stauts: item.has_stauts == 1 })) + draft.applyStatus = _applyStatus }) } @@ -80,7 +86,7 @@ export default function detail () { }, [userInfo, isLogin]) - const { isLoading, activeInfo = {}, visible, formInfo, checked, status, isShare, alwaysBackUrl, isSub } = state + const { isLoading, activeInfo = {}, changci, visible, formInfo, checked, status, isShare, alwaysBackUrl, isSub, applyStatus } = state const handleConfirm = async () => { if (!isLogin || !userInfo) return @@ -205,6 +211,7 @@ export default function detail () { draft.isSub = false }) } + const onClickShare = () => { setState((draft) => { draft.visible = true @@ -230,6 +237,22 @@ export default function detail () { }, 800) } + const handleGoApply = (item) => { + if (item.has_stauts) { + navigateTo('/pages/recommend/status?id=' + activeInfo.activity_id + '&time=') + } else { + if (applyStatus) return + navigateTo('/pages/recommend/apply?id=' + activeInfo.activity_id + '&time=') + Taro.navigateTo({ + url: '/pages/recommend/apply?id=' + activeInfo.activity_id, + success: (res) => { + res.eventChannel.emit('apply', item) + } + }) + + } + } + const formItem = activeInfo.formdata?.key_index || [] // !!activeInfo?.total_count ? <> : // renderFooter={!!activeInfo?.total_count ? <> : renderFooter()} @@ -242,7 +265,7 @@ export default function detail () { {activeInfo.activity_name} - {activeInfo.start} - {activeInfo.end} + {activeInfo.start == activeInfo.end ? activeInfo.start : `${activeInfo.start} - ${activeInfo.end}`} {activeInfo.address} @@ -255,9 +278,9 @@ export default function detail () { - {[{}, {}, {}].map((item, index) => - 第{index + 1}场 13:00-14:00 - navigateTo('/pages/recommend/apply?id=' + activeInfo.activity_id + '&time=' + index)} >{2}席可选 + {changci.length > 0 && changci.map((item, index) => + 第{item.index}场 {item.start}-{item.end} + handleGoApply(item)} >{item.has_stauts ? '已报名' : `${item.limit - item.join}席可选`} )} diff --git a/src/pages/recommend/status.js b/src/pages/recommend/status.js index 2c08634..dcfa45d 100644 --- a/src/pages/recommend/status.js +++ b/src/pages/recommend/status.js @@ -18,13 +18,15 @@ const initState = { loading: true, activeInfo: {}, qrUrl: '', - visible: false + visible: false, + session: {}, + record: {} } export default function status () { const $instance = getCurrentInstance() const [state, setState] = useImmer(initState) const [showModal, setShowModal] = useState(false) - const { cur_activity_info, loading, activeInfo, qrUrl, visible } = state + const { cur_activity_info, loading, activeInfo, qrUrl, visible, session, record } = state useEffect(() => { getActiveDetail() @@ -32,23 +34,25 @@ export default function status () { const getActiveDetail = async () => { const { id, success } = $instance.router.params - const { activity_info = {}, total_count, user_code, recordList = {} } = await api.user.registrationActivity({ activity_id: id }) + const { activity_info = {}, changci = [], total_count, recordList = {} } = await api.user.registrationActivity({ activity_id: id }) const _start = dayjs(activity_info.start_time * 1000) const _end = dayjs(activity_info.end_time * 1000) + const _session = changci.find(item => item.has_stauts == 1) || {} + const _item = _session.recordList?.[0] || {} let url = '' const qrData = JSON.stringify({ activity_id: id, - user_code: user_code || '' + user_code: _item.user_code || '' }) await QRCode.toDataURL(qrData).then((_url) => { url = _url }) - const _item = recordList.list?.[0] || {} const list = _item.content?.[0]?.formdata || [] const record = {} list.map((item) => { record[item.field_name] = item.answer || '' }) + console.log("🚀 ~ file: status.js:52 ~ record:", _item) setState(draft => { draft.activeInfo = { ...activity_info, @@ -60,6 +64,8 @@ export default function status () { } draft.loading = false draft.qrUrl = url + draft.session = _session + draft.record = _item }) } @@ -126,7 +132,8 @@ export default function status () { // if (!res.confirm) return const { id } = $instance.router.params await api.user.cancelRegistrationRecord({ - activity_id: id + activity_id: id, + registration_session_id: session?.registration_session_id }) navigateTo('/pages/index') } @@ -149,12 +156,12 @@ export default function status () { imageUrl: `${process.env.APP_IMAGE_CDN_NEW}/share-logo.jpg` } }) - + // {activeInfo.status === 'pending' ? '待审核' : '报名成功'} return ( - + {/* */} - {activeInfo.status === 'pending' ? '待审核' : activeInfo.status === 'done' ? '已签到' : "已报名 待通过"} + {activeInfo.status === 'done' ? '已签到' : "待签到"} @@ -173,20 +180,22 @@ export default function status () { {activeInfo?.mobile} - 同行朋友 - - - 姓名 - {activeInfo?.username} + {activeInfo?.has_partner === '是' && <> + 同行朋友 + + + 姓名 + {activeInfo?.partner_name} + + + 手机号 + {activeInfo?.partner_mobile} + - - 手机号 - {activeInfo?.mobile} - - + } 活动时间 - {activeInfo?.start} - {activeInfo?.end} + {activeInfo.start == activeInfo.end ? activeInfo.start : `${activeInfo.start} - ${activeInfo.end} ${session.start_time.substr(11, 5)} - ${session.end_time.substr(11, 5)}`} 活动地点 @@ -201,7 +210,7 @@ export default function status () { 入场请出示预约凭证 - : } + : } {activeInfo.status !== 'done' && setShowModal(true)}>取消预约} setShowModal(false)} - onCancel={() => handleCancel} + onCancel={handleCancel} onConfirm={() => { setShowModal(false) }} diff --git a/src/pages/recommend/status.scss b/src/pages/recommend/status.scss index 5c3166d..4a8aabe 100644 --- a/src/pages/recommend/status.scss +++ b/src/pages/recommend/status.scss @@ -1,5 +1,8 @@ .page-recommend-status { padding: 10px 58px; + .sp-page-body { + padding-bottom: 50px; + } .sp-checkbox-new { padding: 30px 0; .icon-checkbox-xuanzhong { diff --git a/src/subpages/member/scan.js b/src/subpages/member/scan.js index ddbad12..785498d 100644 --- a/src/subpages/member/scan.js +++ b/src/subpages/member/scan.js @@ -60,7 +60,7 @@ export default function scan () { } const getRecords = async () => { - const data = await api.user.getVerifyRegistrationRecordList({ activity_id: 1 }) + const data = await api.user.getVerifyRegistrationRecordList({ activity_id: 2 }) const _list = (data?.list || []).map(item => { let formData = item.content?.[0]?.formdata || [] if (formData.length > 0) { diff --git a/src/utils/index.js b/src/utils/index.js index ac5c0d0..830f636 100755 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -429,8 +429,8 @@ export const meiqiaInit = () => { } const redirectUrl = async (api, url, type = 'redirectTo') => { - if (!browser.weixin) { - Taro[type]({ url }) + if (!browser?.weixin) { + typeof url === 'string' && Taro[type]({ url }) return } let newUrl = getUrl(url)