绿满眶商城微信小程序-uniapp
zhanghua
2025-05-28 46a0c082ee5b737a7cbaa3a6b33074a25806235d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<template>
    <view class="add-goods">
        <div class="uForm">
            <u-form :border-bottom="false" :model="form" ref="uForm" :error-type="['toast']" :rule="rules">
 
                <u-form-item label="商品分类" label-width="130" prop="">
                    <div @click="showPicker">
                        {{ form.___path || '请选择所在地区' }}
                    </div>
                </u-form-item>
 
                <u-form-item class="border" label="商品名称" label-width="130" prop="name">
                    <u-input v-model="form.name" clearable placeholder="请输入商品名称" />
                </u-form-item>
 
                <u-form-item label="商品价格" label-width="130" prop="mobile">
                    <u-input v-model="form.mobile" type="number" maxlength="11" placeholder="请输入商品价格" />
                </u-form-item>
                <u-form-item class="detailgoods" label="详细地址" label-width="130" prop="detail">
                    <u-input type="textarea" v-model="form.detail" maxlength="100" height="150" placeholder="街道楼牌号等" />
                </u-form-item>
                <u-form-item label="商品卖点" label-width="130">
                    <u-input type="textarea" v-model="form.alias" placeholder="请输入商品卖点" />
                </u-form-item>
 
                <u-form-item label="商品品牌" label-width="130" prop="">
                    <div @click="showPicker">
                        {{ form.___path || '请选择所在地区' }}
                    </div>
                </u-form-item>
 
                <u-form-item label="计量单位" label-width="130" prop="___path">
                    <div @click="showPicker">
                        {{ form.___path || '请选择所在地区' }}
                    </div>
                </u-form-item>
 
 
                <view class="opt-view">
                    <view class="img-title">上传图片(最多5张)</view>
                    <view class="images-view">
                        <u-upload :header="{ accessToken: storage.getAccessToken() }" :action="action" width="150"
                            @on-uploaded="onUploaded" :max-count="5" :show-progress="false"></u-upload>
                    </view>
                </view>
 
                <div class="saveBtn" @click="save">保存</div>
            </u-form>
 
            <m-city :provinceData="list" headTitle="区域选择" ref="cityPicker" @funcValue="getpickerParentValue"
                pickerSize="4">
            </m-city>
 
            <uniMap v-if="mapFlag" @close="closeMap" @callback="callBackgoods" />
        </div>
    </view>
</template>
 
<script>
export default {
    data() {
        return {
            form: {}
        }
    },
    methods: {
        //图片上传
        onUploaded(lists) {
            let images = [];
 
            lists.forEach((item) => {
                images.push(item.response.result);
            });
            this.form.images = images;
        },
    },
 
    onLoad(option) {
        uni.showLoading({
            title: "加载中",
        });
        this.routerVal = option;
        console.log(option);
 
        if (option.id) {
            getGoodsDetail(option.id).then((res) => {
                const params = res.data.result;
                params.___path = params.consigneegoodsPath;
                this.$set(this, "form", params);
 
                if (this.$store.state.isShowToast) { uni.hideLoading() };
            });
        }
        uni.hideLoading();
    },
}
</script>
 
<style scoped lang="scss">
.detailgoods {
    /deep/ .u-form-item--left {
        display: flex;
        align-items: flex-start;
    }
}
 
.saveBtn,
.selectgoods {
    height: 70rpx;
 
    line-height: 70rpx;
    text-align: center;
    font-size: 30rpx;
    background: $aider-light-color;
    color: #fff;
    width: 70%;
    margin: 40rpx auto 0 auto;
    border-radius: 20rpx;
}
 
.selectgoods {
    margin-top: 40rpx;
    background: #fff;
 
    color: $aider-light-color;
    border: 2rpx solid $aider-light-color;
}
 
.uForm {
    width: 94%;
    overflow: hidden;
    left: 3%;
    position: relative;
    top: 2%;
    background: #fff;
    border-radius: 20rpx;
    padding: 0 0 40rpx 0;
}
 
.add-goods {
    width: 100%;
    padding-top: 3%;
 
    /deep/ .u-form-item {
        background-color: #fff;
        padding: 24rpx 30rpx;
    }
 
    .u-btn {
        margin: 30rpx 30rpx 0 30rpx;
        background-color: $main-color;
    }
 
    /deep/.u-checkbox {
        margin: 30rpx 30rpx 0 30rpx;
 
        .u-label-class.u-checkbox__label {
            color: $font-color-light;
            font-size: $font-sm;
        }
    }
}
 
/deep/ .u-checkbox__label {
    font-size: 28rpx;
}
</style>