【优化】调整地图选点插件,让其支持支付宝小程序。

This commit is contained in:
jianweie code
2024-05-06 11:18:16 +08:00
parent c6cd50c51b
commit 5be1f7789b

View File

@@ -16,16 +16,17 @@
</view> </view>
<view class="coreshop-padding-10"> <view class="coreshop-padding-10">
<u--form :model="form" :rules="rules" ref="uForm" errorType="message" labelPosition="left" labelWidth="80"> <u--form :model="form" :rules="rules" ref="uForm" errorType="message" labelPosition="left">
<u-form-item label="收货人" prop="name" borderBottom clearValidate> <u-form-item label="收货人" labelWidth="80" prop="name" borderBottom clearValidate>
<u--input v-model="form.name" placeholder="请填写收货人姓名" /> <u--input v-model="form.name" placeholder="请填写收货人姓名" />
</u-form-item> </u-form-item>
<u-form-item label="手机号" prop="mobile" borderBottom clearValidate> <u-form-item label="手机号" labelWidth="80" prop="mobile" borderBottom clearValidate>
<u--input v-model="form.mobile" placeholder="请填写收货人手机号" /> <u--input v-model="form.mobile" placeholder="请填写收货人手机号" />
</u-form-item> </u-form-item>
<u-form-item label="省市县" borderBottom> <u-form-item label="省市县" labelWidth="80" borderBottom>
<coreshop-select v-model="show" mode="mutil-column-auto" :list="pickerList" :default-value="pickerIndex" @confirm="onConfirm"></coreshop-select> <coreshop-select v-model="show" mode="mutil-column-auto" :list="pickerList"
:default-value="pickerIndex" @confirm="onConfirm"></coreshop-select>
<!-- 注意由于兼容性差异如果需要使用前后插槽nvue下需使用u--input非nvue下需使用u-input --> <!-- 注意由于兼容性差异如果需要使用前后插槽nvue下需使用u--input非nvue下需使用u-input -->
<!-- #ifndef APP-NVUE --> <!-- #ifndef APP-NVUE -->
<u-input :value="pickerValue" type="select" disabled placeholder="请选择省市区区域"> <u-input :value="pickerValue" type="select" disabled placeholder="请选择省市区区域">
@@ -45,7 +46,7 @@
<!-- #endif --> <!-- #endif -->
</u-form-item> </u-form-item>
<u-form-item label="街道社区" borderBottom @click="toMap"> <u-form-item label="街道社区" labelWidth="80" borderBottom @click="toMap">
<!-- 注意由于兼容性差异如果需要使用前后插槽nvue下需使用u--input非nvue下需使用u-input --> <!-- 注意由于兼容性差异如果需要使用前后插槽nvue下需使用u--input非nvue下需使用u-input -->
<!-- #ifndef APP-NVUE --> <!-- #ifndef APP-NVUE -->
<u-input :value="form.street" type="text" disabled placeholder="请定位"> <u-input :value="form.street" type="text" disabled placeholder="请定位">
@@ -71,33 +72,36 @@
<u--input v-model="form.latitude" disabled placeholder="请选择街道获取纬度" /> <u--input v-model="form.latitude" disabled placeholder="请选择街道获取纬度" />
</u-form-item>--> </u-form-item>-->
<u-form-item label="详细地址" prop="address" borderBottom clearValidate> <u-form-item label="详细地址" labelWidth="80" prop="address" borderBottom clearValidate>
<u--textarea v-model="form.address" placeholder="请输入内容"></u--textarea> <u--textarea v-model="form.address" placeholder="请输入内容"></u--textarea>
<!--<u--input v-model="form.address" placeholder="请填写收货详细地址" type="textarea" />--> <!--<u--input v-model="form.address" placeholder="请填写收货详细地址" type="textarea" />-->
</u-form-item> </u-form-item>
<u-form-item label="设为默认"> <u-form-item label="设为默认" labelWidth="80">
<u-switch slot="right" v-model="checked"></u-switch> <u-switch slot="right" v-model="checked"></u-switch>
</u-form-item> </u-form-item>
</u--form> </u--form>
</view> </view>
<view class="coreshop-bottomBox"> <view class="coreshop-bottomBox">
<button class="coreshop-btn coreshop-btn-square coreshop-btn-w" @click="delShip" v-if="id && id != 0" :disabled='submitStatus' :loading='submitStatus'>删除</button> <button class="coreshop-btn coreshop-btn-square coreshop-btn-w" @click="delShip" v-if="id && id != 0"
:disabled='submitStatus' :loading='submitStatus'>删除</button>
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<button class="coreshop-btn coreshop-btn-square coreshop-btn-w" @click="wechatAddress" v-if="!id">从微信获取</button> <button class="coreshop-btn coreshop-btn-square coreshop-btn-w" @click="wechatAddress"
v-if="!id">从微信获取</button>
<!-- #endif --> <!-- #endif -->
<button class="coreshop-btn coreshop-btn-square coreshop-btn-b" @click="saveShip" :disabled='submitStatus' :loading='submitStatus'>保存</button> <button class="coreshop-btn coreshop-btn-square coreshop-btn-b" @click="saveShip" :disabled='submitStatus'
:loading='submitStatus'>保存</button>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
const chooseLocation = requirePlugin('chooseLocation'); const chooseLocation = requirePlugin('chooseLocation');
// #endif // #endif
// #ifdef APP-PLUS || APP-PLUS-NVUE // #ifdef APP-PLUS || APP-PLUS-NVUE
// #endif // #endif
export default { export default {
data() { data() {
return { return {
getType: 1, //1手动输入0从微信获取 getType: 1, //1手动输入0从微信获取
@@ -449,6 +453,7 @@
this.pickerIndex = [this.provinceKey, this.cityKey, this.areaKey]; this.pickerIndex = [this.provinceKey, this.cityKey, this.areaKey];
}, },
toMap() { toMap() {
const _this = this;
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
const txMapkey = this.$store.state.config.qqMapKey; //使用在腾讯位置服务申请的key const txMapkey = this.$store.state.config.qqMapKey; //使用在腾讯位置服务申请的key
const referer = this.$store.state.config.shopName; //调用插件的app的名称 const referer = this.$store.state.config.shopName; //调用插件的app的名称
@@ -464,6 +469,22 @@
}); });
// #endif // #endif
// #ifdef MP-ALIPAY
my.chooseLocation({
latitude: this.form.latitude == "" ? this.latitude : this.form.latitude,
longitude: this.form.longitude == "" ? this.longitude : this.form.longitude,
success: function (res) {
console.log(res);
_this.form.latitude = res.latitude;
_this.form.longitude = res.longitude;
_this.form.street = res.address;
},
fail: function (err) {
console.log(err);
}
});
// #endif
// #ifdef APP-PLUS || APP-PLUS-NVUE // #ifdef APP-PLUS || APP-PLUS-NVUE
uni.chooseLocation({ uni.chooseLocation({
success: (res) => { success: (res) => {
@@ -516,8 +537,10 @@
}, },
} }
</script> </script>
<style lang="scss"> <style lang="scss">
page { background: #fff; } page {
background: #fff;
}
</style> </style>