li.shaoyi 3 年之前
父节点
当前提交
2b983671e3

+ 1 - 0
fxgl.txt

@@ -3,6 +3,7 @@ key Alias : fxgl
 key Password : muchinfo
 
 cn.muchinfo.thj_debug_v1.0.0.apk
+cn.muchinfo.thj_demo_v1.0.0.apk
 cn.muchinfo.thj_release_v1.0.0.apk
 
 Go服务:http://101.133.236.116:8280/cfg?key=mtp_20

+ 0 - 1
src/business/credit/index.ts

@@ -89,7 +89,6 @@ export function useCreditLottery() {
             },
             success: (res) => {
                 redEnvelope.value = res
-                formRefresh()
             },
             complete: () => {
                 loading.value = false

二进制
src/packages/mobile/assets/images/hongbao.png


+ 3 - 6
src/packages/mobile/components/base/region/index.less

@@ -1,10 +1,7 @@
 .app-region {
-    flex: 1;
-
-    &__wrapper {
-        display    : flex;
-        align-items: center;
-    }
+    flex       : 1;
+    display    : flex;
+    align-items: center;
 
     &__input {
         flex : 1;

+ 12 - 9
src/packages/mobile/components/base/region/index.vue

@@ -1,12 +1,10 @@
 <template>
-    <div class="app-region">
-        <div class="app-region__wrapper" @click="show = true">
-            <slot :value="inputValue">
-                <input class="app-region__input" v-model="inputValue" :placeholder="placeholder" readonly />
-            </slot>
-        </div>
+    <div class="app-region" @click="show = true">
+        <slot :value="inputValue">
+            <input class="app-region__input" v-model="inputValue" :placeholder="placeholder" readonly />
+        </slot>
         <Popup v-model:show="show" position="bottom" teleport="body" round>
-            <Cascader :title="title" v-model="selectedValue" :options="options" @close="show = false"
+            <Cascader :title="title" v-model="selectedValue" :options="options" @close="show = false" @change="onChange"
                 @finish="onFinish" />
         </Popup>
     </div>
@@ -36,7 +34,7 @@ const props = defineProps({
     },
 })
 
-const emit = defineEmits(['update:modelValue', 'finish'])
+const emit = defineEmits(['update:modelValue', 'change', 'finish'])
 const show = shallowRef(false) // 是否弹出选择器
 const inputValue = shallowRef('')
 const options = shallowRef<CascaderOption[]>([])
@@ -47,13 +45,18 @@ const selectedValue = computed({
     set: (val) => emit('update:modelValue', val)
 })
 
+// 选中项变化时触发
+const onChange = ({ value }: { value: string | number }) => {
+    emit('change', value)
+}
+
 // 全部选项选择完毕后触发
 const onFinish = ({ selectedOptions }: { selectedOptions: CascaderOption[] }) => {
     const selection = selectedOptions.map((e) => e.value)
     show.value = false
     inputValue.value = selectedOptions.map((option) => option.text).join(' ')
 
-    emit('update:modelValue', selection.pop())
+    emit('update:modelValue', [...selection].pop())
     emit('finish', selection)
 }
 

+ 3 - 6
src/packages/mobile/components/base/select/index.less

@@ -1,10 +1,7 @@
 .app-select {
-    flex: 1;
-
-    &__wrapper {
-        display    : flex;
-        align-items: center;
-    }
+    flex       : 1;
+    display    : flex;
+    align-items: center;
 
     &__input {
         flex : 1;

+ 4 - 6
src/packages/mobile/components/base/select/index.vue

@@ -1,10 +1,8 @@
 <template>
-    <div class="app-select">
-        <div class="app-select__wrapper" @click="show = true">
-            <slot :value="inputValue">
-                <input class="app-select__input" v-model="inputValue" :placeholder="placeholder" readonly />
-            </slot>
-        </div>
+    <div class="app-select" @click="show = true">
+        <slot :value="inputValue">
+            <input class="app-select__input" v-model="inputValue" :placeholder="placeholder" readonly />
+        </slot>
         <Popup v-model:show="show" position="bottom" teleport="body">
             <Picker :columns="columns" @cancel="onCancel" @confirm="onConfirm" />
         </Popup>

+ 6 - 7
src/packages/mobile/components/modules/reward/index.less

@@ -7,10 +7,12 @@
         position : relative;
         font-size: 200%;
         color    : #ffff00;
+        width    : 4.93rem;
+        height   : 6.39rem;
 
         .content {
             position  : absolute;
-            top       : 40%;
+            top       : 1.2rem;
             width     : 100%;
             text-align: center;
             transition: transform 500ms;
@@ -36,13 +38,10 @@
 
         .buttons {
             position  : absolute;
-            bottom    : 12%;
-            width     : 100%;
+            bottom    : -.8rem;
+            color     : #fff;
             text-align: center;
-
-            .van-button {
-                width: 50%;
-            }
+            width     : 100%;
         }
     }
 }

+ 5 - 9
src/packages/mobile/components/modules/reward/index.vue

@@ -1,7 +1,7 @@
 <template>
     <Overlay class="app-reward" :show="show">
         <div class="app-reward__wrapper" @click.stop>
-            <img src="@mobile/assets/images/hongbao.png" />
+            <img class="image" src="@mobile/assets/images/hongbao.png" @click="showRedEnvelope = true" />
             <div class="content" v-if="!showRedEnvelope">
                 <h1>{{ title }}</h1>
             </div>
@@ -9,9 +9,8 @@
                 <h1>恭喜获得红包</h1>
                 <p>{{ value?.toFixed(2) }}</p>
             </div>
-            <div class="buttons">
-                <Button @click="$emit('click')" round v-if="showRedEnvelope">{{ buttonText }}</Button>
-                <Button @click="showRedEnvelope = true" round v-else>打开红包</Button>
+            <div class="buttons" v-if="showRedEnvelope">
+                <Icon name="close" @click="emit('click')" />
             </div>
         </div>
     </Overlay>
@@ -19,7 +18,7 @@
 
 <script lang="ts" setup>
 import { shallowRef, watch } from 'vue'
-import { Button, Overlay } from 'vant'
+import { Overlay, Icon } from 'vant'
 
 const props = defineProps({
     show: {
@@ -31,12 +30,9 @@ const props = defineProps({
         default: 0
     },
     title: String,
-    buttonText: {
-        type: String,
-        default: '好的'
-    }
 })
 
+const emit = defineEmits(['click'])
 const showRedEnvelope = shallowRef(false)
 
 watch(() => props.show, (status) => {

+ 0 - 59
src/packages/mobile/views/credit/lottery/components/reward/index.less

@@ -1,59 +0,0 @@
-.lottery-reward {
-    display        : flex;
-    justify-content: center;
-    align-items    : center;
-
-    &__wrapper {
-        display        : flex;
-        flex-direction : column;
-        justify-content: space-between;
-        width          : 7.04rem;
-        height         : 9.56rem;
-        background     : url('@mobile/assets/images/lottery/lottery-red-envelope.png') no-repeat;
-        background-size: contain;
-    }
-
-    &__content {
-        font-size  : .72rem;
-        font-weight: bold;
-        text-align : center;
-        color      : #f34868;
-        padding-top: 3.2rem;
-
-        &::after {
-            content  : '元';
-            font-size: large;
-        }
-    }
-
-    &__footer {
-        text-align    : center;
-        padding-bottom: 1.5rem;
-
-        button {
-            width        : 3.64rem;
-            height       : 1.04rem;
-            font-size    : .36rem;
-            font-weight  : bold;
-            color        : #8F4301;
-            background   : linear-gradient(180deg, #FDEFDA 0%, #FFBE7A 100%);
-            box-shadow   : inset 0 -.04rem 1rem 0 #FFDBAC;
-            border-radius: .52rem;
-        }
-
-        .tips {
-            display       : flex;
-            flex-direction: column;
-            color         : #FAF7DE;
-            font-size     : .4rem;
-            font-weight   : bold;
-            margin-bottom : .32rem;
-
-            span {
-                &:first-child {
-                    margin-bottom: .12rem;
-                }
-            }
-        }
-    }
-}

+ 0 - 66
src/packages/mobile/views/credit/lottery/components/reward/index.vue

@@ -1,66 +0,0 @@
-<template>
-    <Overlay class="lottery-reward" :show="showReward">
-        <div class="lottery-reward__wrapper">
-            <div class="lottery-reward__content">
-                <span>{{ value.toFixed(2) }}</span>
-            </div>
-            <div class="lottery-reward__footer">
-                <div class="tips">
-                    <template v-if="value">
-                        <span>恭喜您获得</span>
-                        <span>{{ levelText }}</span>
-                    </template>
-                    <template v-else>
-                        <span>{{ levelText }}</span>
-                    </template>
-                </div>
-                <button type="button" @click="showReward = false">开心收下</button>
-            </div>
-        </div>
-    </Overlay>
-</template>
-
-<script lang="ts" setup>
-import { computed } from 'vue'
-import { Overlay } from 'vant'
-
-const props = defineProps({
-    show: {
-        type: Boolean,
-        default: false
-    },
-    value: {
-        type: Number,
-        default: 0
-    },
-    level: {
-        type: Number,
-        default: 0
-    },
-})
-
-const emit = defineEmits(['update:show'])
-
-const showReward = computed({
-    get: () => props.show,
-    set: (val) => emit('update:show', val)
-})
-
-const levelText = computed(() => {
-    switch (props.level) {
-        case 1: {
-            return '一等奖'
-        }
-        case 2: {
-            return '二等奖'
-        }
-        default: {
-            return '谢谢参与'
-        }
-    }
-})
-</script>
-
-<style lang="less">
-@import './index.less';
-</style>

+ 6 - 2
src/packages/mobile/views/credit/lottery/index.vue

@@ -44,8 +44,7 @@
                 </dl>
             </div>
         </div>
-        <app-reward :show="showReward" :value="redEnvelope.RedPacketAmount" button-text="开心收下"
-            @click="showReward = false" />
+        <app-reward :show="showReward" :value="redEnvelope.RedPacketAmount" @click="onClick" />
     </app-view>
 </template>
 
@@ -59,6 +58,11 @@ import AppReward from '@mobile/components/modules/reward/index.vue'
 const { creditConfig, userAccount, creditList, redEnvelope, formSubmit, formRefresh } = useCreditLottery()
 const showReward = shallowRef(false) // 显示抽奖红包
 
+const onClick = () => {
+    showReward.value = false
+    formRefresh()
+}
+
 const onSubmit = () => {
     const { curscore = 0 } = userAccount.value
     const { parma1 = 0 } = creditConfig.value

+ 40 - 11
src/packages/mobile/views/mine/address/components/edit/index.vue

@@ -6,16 +6,17 @@
             </template>
             <Form ref="formRef" class="g-form__container" @submit="formSubmit">
                 <CellGroup inset>
-                    <Field v-model="formData.ReceiverName" name="ReceiverName" label="收货人" placeholder="必填"
-                        :rules="formRules.ReceiverName" />
-                    <Field v-model="formData.PhoneNum" type="tel" name="PhoneNum" label="联系电话" placeholder="必填"
-                        :rules="formRules.PhoneNum" />
-                    <Field label="收货地区" placeholder="请选择" is-link>
+                    <Field v-model="formData.ReceiverName" :rules="formRules.ReceiverName" name="ReceiverName"
+                        label="收货人" placeholder="必填" />
+                    <Field v-model="formData.PhoneNum" :rules="formRules.PhoneNum" type="tel" name="PhoneNum"
+                        label="联系电话" placeholder="必填" />
+                    <Field :rules="formRules.Region" name="Region" label="收货地区" placeholder="请选择" is-link>
                         <template #input>
-                            <app-region v-model="formData.DistrictID" />
+                            <app-region v-model="formData.DistrictID" @finish="onRegionFinish" />
                         </template>
                     </Field>
-                    <Field v-model="formData.Address" name="refernum" label="详细地址" placeholder="详细地址" />
+                    <Field v-model="formData.Address" :rules="formRules.Address" name="Address" label="详细地址"
+                        placeholder="必填" />
                 </CellGroup>
             </Form>
             <template #footer>
@@ -28,9 +29,9 @@
 </template>
 
 <script lang="ts" setup>
-import { reactive, shallowRef, PropType } from 'vue'
+import { shallowRef, PropType } from 'vue'
 import { CellGroup, Button, Field, Form, FormInstance, Toast, FieldRule } from 'vant'
-import { fullloading, dialog } from '@/utils/vant'
+import { fullloading } from '@/utils/vant'
 import { validateRules } from '@/constants/regex'
 import { useNavigation } from '@/hooks/navigation'
 import { useAddressForm } from '@/business/user'
@@ -50,11 +51,39 @@ const formRef = shallowRef<FormInstance>()
 const showModal = shallowRef(true)
 
 // 表单验证规则
-const formRules: { [key in keyof Proto.UserReceiveInfoReq]?: FieldRule[] } = {
+const formRules: { [key in keyof Proto.UserReceiveInfoReq | 'Region']?: FieldRule[] } = {
     ReceiverName: [{
         required: true,
         message: '请输入收货人',
     }],
+    PhoneNum: [{
+        required: true,
+        message: '请输入联系电话',
+        validator: (val) => {
+            if (validateRules.phone.validate(val)) {
+                return true
+            }
+            return validateRules.phone.message
+        }
+    }],
+    Region: [{
+        message: '请选择收货地区',
+        validator: () => {
+            return !!formData.ProvinceID && !!formData.CityID && !!formData.DistrictID
+        }
+    }],
+    Address: [{
+        required: true,
+        message: '请输入详细地址',
+    }],
+}
+
+// 选择地区
+const onRegionFinish = ([province, city, district]: number[]) => {
+    formData.ProvinceID = province
+    formData.CityID = city
+    formData.DistrictID = district
+    formRef.value?.validate('Region')
 }
 
 // 表单提交
@@ -62,7 +91,7 @@ const formSubmit = () => {
     fullloading((hideLoading) => {
         addOrUpdate().then(() => {
             hideLoading()
-            Toast.fail('保存成功')
+            router.back()
         }).catch((err) => {
             Toast.fail(err)
         })

+ 1 - 0
src/packages/mobile/views/mine/address/index.less

@@ -0,0 +1 @@
+.mine-address {}

+ 37 - 8
src/packages/mobile/views/mine/address/index.vue

@@ -3,28 +3,57 @@
         <template #header>
             <app-navbar title="收货地址管理" />
         </template>
-        <AddressList v-model="chosenAddressId" @add="onAdd" />
-        <component ref="componentRef" :is="componentMap.get(componentId)" @closed="closeComponent" v-if="componentId" />
+        <div class="mine-address__container">
+            <ul class="list">
+                <li class="list-item" v-for="(item, index) in dataList" :key="index">
+                    <div class="list-item__">
+                        <Checkbox v-model="item.isdefault" />
+                    </div>
+                    <div class="list-item__">
+                        <div>{{ item.receivername }}</div>
+                        <div>{{ [item.provincename, item.cityname, item.districtname, item.address].join(' ') }}</div>
+                    </div>
+                    <div class="list-item__">
+                        <Button icon="edit" @click="onEdit(item)" />
+                    </div>
+                </li>
+            </ul>
+        </div>
+        <template #footer>
+            <div class="g-form__footer">
+                <Button type="primary" @click="onEdit" round block>新增地址</Button>
+            </div>
+            <component ref="componentRef" v-bind="{selectedRow}" :is="componentMap.get(componentId)"
+                @closed="closeComponent" v-if="componentId" />
+        </template>
     </app-view>
 </template>
 
 <script lang="ts" setup>
-import { ref, defineAsyncComponent } from 'vue'
-import { AddressList } from 'vant'
+import { shallowRef, defineAsyncComponent } from 'vue'
+import { Checkbox, Button } from 'vant'
 import { useNavigation } from '@/hooks/navigation'
 import { useComponent } from '@/hooks/component'
+import { useAddress } from '@/business/user'
 
 const componentMap = new Map<string, unknown>([
     ['edit', defineAsyncComponent(() => import('./components/edit/index.vue'))],
 ])
 
 const { beforeRouteLeave } = useNavigation()
-const { componentRef, componentId, openComponent, closeComponent, closeComponentEach } = useComponent()
-const chosenAddressId = ref(0)
+const { dataList, getUserAddressList } = useAddress()
+const { componentRef, componentId, openComponent, closeComponent, closeComponentEach } = useComponent(getUserAddressList)
+const selectedRow = shallowRef<Model.UserReceiveInfoRsp>()
 
-const onAdd = () => {
+const onEdit = (item?: Model.UserReceiveInfoRsp) => {
+    selectedRow.value = item
     openComponent('edit')
 }
 
+getUserAddressList()
 beforeRouteLeave(() => closeComponentEach())
-</script>
+</script>
+
+<style lang="less">
+@import './index.less';
+</style>

+ 1 - 1
src/packages/mobile/views/user/register/index.vue

@@ -43,7 +43,7 @@
       <div class="g-form__footer">
         <Button type="primary" @click="formRef?.submit" round block>免费注册</Button>
       </div>
-      <app-reward :show="showReward" :value="redEnvelope" title="注册成功!" button-text="去登录" @click="router.back()" />
+      <app-reward :show="showReward" :value="redEnvelope" title="注册成功!" @click="router.back()" />
     </template>
   </app-view>
 </template>