123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- <template>
- <view class="">
- <view style="padding:30rpx">
- <view class="box">
- <view class="box-top">
- <view class="title">
- <text>下单人</text>
- <text class="star">*</text>
- </view>
- <input v-model="buyForm.buy_name" type="text" class="box-input" placeholder-class="input_placeholder"
- placeholder="请填写真实姓名" />
- </view>
- <view class="box-top">
- <navigator url="./phone-area" class="phone-area flexB">
- <view class="flexS">
- <view class="title">
- <text class="text">国家/地区</text>
- <text class="star">*</text>
- </view>
- <text class="area">{{areaName}}({{buyForm.buy_code}})</text>
- </view>
- <text class="icon cuIcon-right"></text>
- </navigator>
- </view>
- <view class="box-top">
- <view class="title">
- <text>手机号</text>
- <text class="star">*</text>
- </view>
- <input v-model="buyForm.buy_phone" type="number" class="box-input" placeholder-class="input_placeholder"
- placeholder="请填写手机号码" maxlength="11" />
- </view>
- </view>
- </view>
- <view class="bottom">
- <view class="bottom-btn" @tap="save">保存信息</view>
- </view>
- </view>
- </template>
- <script>
- // import {
- // _API_AddressAdd,
- // _API_AddressUpdata,
- // discernAdress
- // } from '@/apis/address.js';
- import areaList from '@/common/util/phone-area.js'
- export default {
- data() {
- return {
- id: '',
- message: '',
- result: '',
- buyForm: {
- buy_name: '',
- buy_phone: '',
- buy_code: '+86', // 手机号地区代码
- },
- requesting: false,
- areaName: '中国大陆', // 手机号地区名称
- isMatch: /^[1][3-9]\d{9}$/, //手机号验证
- codeList: areaList, //手机号区域选择
- };
- },
- onLoad(option) {
- uni.$on('CHOOSEPHONECODE', (name, code, reg, phoneReg) => {
- // 监听 chooseArea 事件更新
- this.areaName = name; // 修改选择的手机号地区名称
- this.buyForm.buy_code = code // 修改选择的手机号地区代码
- this.isMatch = phoneReg
- })
- if (option.data) {
- this.buyForm = JSON.parse(decodeURIComponent(option.data))
- if (this.buyForm.buy_code) {
- let index = this.buyForm.buy_code.indexOf('+')
- let code = this.buyForm.buy_code.substring(index + 1)
- this.codeList[0].list.map(i => {
- if (i.code === Number(code)) {
- this.areaName = i.name
- this.isMatch = i.phoneReg
- }
- })
- }
- }
- },
- methods: {
- save() {
- if (this.buyForm.buy_name) {
- this.buyForm.buy_name = this.buyForm.buy_name.replace(/\s*/g, '');
- }
- // 保存/修改地址
- if (!this.buyForm.buy_name.match(/^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/)) {
- // 校验姓名
- uni.showToast({
- title: '真实姓名不符合要求',
- icon: 'none',
- mask: true
- });
- return;
- }
- if (!this.buyForm.buy_phone) {
- uni.showToast({
- title: '手机号码不能为空',
- icon: 'none',
- mask: true
- });
- return
- }
- if (this.isMatch && !this.buyForm.buy_phone.match(this.isMatch)) {
- uni.showToast({
- title: '手机号所属与区号不一致',
- icon: 'none',
- mask: true
- });
- return
- }
- uni.$emit('orderPlace', this.buyForm)
- uni.navigateBack()
- }
- }
- };
- </script>
- <style>
- .input_placeholder {
- font-size: 30rpx;
- color: #cbcbcb;
- }
- </style>
- <style lang="scss" scoped>
- .nav {
- padding: 26rpx 20rpx 30rpx 30rpx;
- background-color: #fff;
- border-radius: 24rpx;
- display: flex;
- flex-direction: column;
- align-items: flex-end;
- .discern {
- width: 100%;
- height: 180rpx;
- font-size: 28rpx;
- &-placeholder {
- color: #c8c8c8;
- font-size: 28rpx;
- line-height: 44rpx;
- }
- }
- .flex {
- display: flex;
- view {
- width: 128rpx;
- height: 64rpx;
- font-size: 28rpx;
- border-radius: 32rpx;
- }
- }
- &-button {
- color: #ffffff;
- background: linear-gradient(90deg, #ff232c 0%, #ff571b 100%);
- }
- &-clearbutton {
- background: #fff4f3;
- border: 2rpx solid $base-color;
- color: $base-color;
- margin-right: 15rpx;
- }
- }
- .box {
- background-color: #fff;
- border-radius: 24rpx;
- .phone-area {
- width: 100%;
- .area {
- color: #049E56;
- font-weight: bold;
- margin-left: 16rpx;
- }
- .icon {
- font-size: 40rpx;
- color: #999;
- }
- }
- &-input {
- font-size: 30rpx;
- min-height: 126rpx;
- width: 75%;
- margin-left: 20rpx;
- }
- &-top {
- min-height: 128rpx;
- margin: 0 30rpx;
- box-sizing: border-box;
- border-bottom: 2rpx solid #eeeeee;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- .title {
- font-size: 34rpx;
- font-weight: bold;
- .star {
- color: $base-color;
- margin-left: 10rpx;
- font-size: 40rpx;
- }
- }
- .picker {
- width: 75%;
- min-height: 128rpx;
- margin-left: 20rpx;
- font-size: 30rpx;
- .iconfont {
- color: #cbcbcb;
- }
- }
- .input_placeholder {
- font-size: 30rpx;
- color: #cbcbcb;
- }
- }
- &-bottom {
- height: 166rpx;
- padding: 20rpx 30rpx;
- box-sizing: border-box;
- border-bottom: 2rpx solid #eeeeee;
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- .title {
- font-size: 34rpx;
- font-weight: bold;
- .star {
- color: $base-color;
- margin-left: 10rpx;
- font-size: 40rpx;
- }
- }
- .input_placeholder {
- font-size: 30rpx;
- color: #cbcbcb;
- }
- .textbox {
- height: 166rpx;
- .box-input {
- width: 440rpx;
- height: 120rpx;
- font-size: 30rpx;
- }
- }
- }
- &-changyong {
- height: 110rpx;
- padding: 26rpx 20rpx 30rpx 30rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .title {
- // width: 146rpx;
- font-size: 28rpx;
- font-weight: 400;
- line-height: 29rpx;
- color: #585858;
- }
- .input_placeholder {
- font-size: 28rpx;
- font-weight: 400;
- line-height: 29rpx;
- }
- .set-used {
- margin-right: auto;
- color: #ea4a41;
- font-size: 30rpx;
- }
- .set-control {
- width: 110rpx;
- height: 55rpx;
- line-height: 55rpx;
- border-radius: 50rpx;
- text-align: center;
- background: #f8f8f8;
- color: #333333;
- font-size: 30rpx;
- &:nth-last-of-type(1) {
- margin-left: 20rpx;
- }
- &.active {
- background: linear-gradient(to right, #f97c55, #f44545) !important;
- color: #ffffff !important;
- }
- }
- }
- }
- .remind {
- text-align: center;
- color: #fb231f;
- font-size: 28rpx;
- }
- .bottom {
- position: fixed;
- bottom: 0;
- width: 100%;
- height: 100rpx;
- background-color: #fff;
- border-top: 1px solid #eeeeee;
- @include flex()
- &-btn {
- width: 702rpx;
- color: #fff;
- text-align: center;
- font-size: 32rpx;
- font-weight: bold;
- line-height: 88rpx;
- height: 88rpx;
- background: linear-gradient(93deg, #ff232c 0%, #ff571b 100%);
- opacity: 1;
- border-radius: 44px;
- }
- }
- </style>
|