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

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 class="coreshop-padding-10">
<u--form :model="form" :rules="rules" ref="uForm" errorType="message" labelPosition="left" labelWidth="80">
<u-form-item label="收货人" prop="name" borderBottom clearValidate>
<u--form :model="form" :rules="rules" ref="uForm" errorType="message" labelPosition="left">
<u-form-item label="收货人" labelWidth="80" prop="name" borderBottom clearValidate>
<u--input v-model="form.name" placeholder="请填写收货人姓名" />
</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-form-item>
<u-form-item label="省市县" borderBottom>
<coreshop-select v-model="show" mode="mutil-column-auto" :list="pickerList" :default-value="pickerIndex" @confirm="onConfirm"></coreshop-select>
<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>
<!-- 注意由于兼容性差异如果需要使用前后插槽nvue下需使用u--input非nvue下需使用u-input -->
<!-- #ifndef APP-NVUE -->
<u-input :value="pickerValue" type="select" disabled placeholder="请选择省市区区域">
@@ -45,7 +46,7 @@
<!-- #endif -->
</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 -->
<!-- #ifndef APP-NVUE -->
<u-input :value="form.street" type="text" disabled placeholder="请定位">
@@ -71,22 +72,25 @@
<u--input v-model="form.latitude" disabled placeholder="请选择街道获取纬度" />
</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--input v-model="form.address" placeholder="请填写收货详细地址" type="textarea" />-->
</u-form-item>
<u-form-item label="设为默认">
<u-form-item label="设为默认" labelWidth="80">
<u-switch slot="right" v-model="checked"></u-switch>
</u-form-item>
</u--form>
</view>
<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 -->
<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 -->
<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>
</template>
@@ -449,6 +453,7 @@
this.pickerIndex = [this.provinceKey, this.cityKey, this.areaKey];
},
toMap() {
const _this = this;
// #ifdef MP-WEIXIN
const txMapkey = this.$store.state.config.qqMapKey; //使用在腾讯位置服务申请的key
const referer = this.$store.state.config.shopName; //调用插件的app的名称
@@ -464,6 +469,22 @@
});
// #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
uni.chooseLocation({
success: (res) => {
@@ -519,5 +540,7 @@
}
</script>
<style lang="scss">
page { background: #fff; }
page {
background: #fff;
}
</style>