123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- <template>
- <view class="add">
- <view class="add_user">
- <view class="inp_box">
- <view class="label">
- <text>介绍人手机号</text>
- <text class="star">*</text>
- </view>
- <navigator url="../phone-area/phone-area" class="flexB phone-area">
- <text class="text">国家/地区</text>
- <view>
- <text class="area">{{ areaName }}({{ areaCode }})</text>
- <text class="iconfont iconiconfontjiantou2"></text>
- </view>
- </navigator>
- <input type="number" placeholder="请输入介绍人手机号" v-model="userPhone" maxlength="11" />
- </view>
- <view style="margin-top:20rpx;" class="inp_box">
- <view class="label">
- <text>介绍人昵称</text>
- <text class="star">*</text>
- </view>
- <input type="text" placeholder="请输入介绍人昵称" v-model="userName" />
- </view>
- <view class="sub_btn_box flexCC">
- <view class="sub_btn" @click="addUser">确认添加</view>
- </view>
- </view>
- <view class="pop flexCC" v-if="showPop">
- <view class="pop_con">
- <view class="hint">
- <image src="../../../static/imgs/shop/hint_icon.png" class="hint_icon"></image>
- <view class="title">确认信息</view>
- </view>
- <view class="con">
- <view>昵称:{{userInfo.nickname}}</view>
- <view style="margin-top:14rpx">手机号:{{userInfo.phone}}</view>
- </view>
- <view class="btn_box flexB">
- <view class="flexC" @click="showPop=false">取消</view>
- <view class="flexC" @click="toBind">确认绑定</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- addUser,
- bindRecomer,
- getAllRecomer,
- editBindRecomer
- } from '@/apis/shop.js';
- export default {
- data() {
- return {
- userPhone: '', //新添加的用户手机号
- userName: '', // 新添加的用户昵称(选填)
- isChecked: false,
- notVip: true,
- is_vip: 0,
- showPop: false,
- order_no: '',
- order_id: '',
- remark: '',
- userInfo: '',
- areaName: '中国大陆', // 手机号地区名称
- areaCode: '+86', // 手机号地区代码
- };
- },
- onLoad(ops) {
- this.order_id = ops.order_id
- this.order_no = ops.order_no
- this.remark = ops.remark
- },
- created() {
- uni.$on('CHOOSEPHONECODE', (name, code) => { // 监听 chooseArea 事件更新
- this.areaName = name // 修改选择的手机号地区名称
- this.areaCode = code // 修改选择的手机号地区代码
- })
- },
- methods: {
- // 绑定介绍人
- toBind() {
- let http = this.remark ? editBindRecomer : bindRecomer
- let data = this.remark ? {
- id: this.userInfo.id,
- order_id: this.order_id,
- remark: this.remark
- } : {
- id: this.userInfo.id,
- order_id: this.order_id,
- }
- http(data).then(res => {
- this.showPop = false
- if (res.code === 200) {
- uni.showModal({
- content: this.remark ? '更换介绍人成功' : '绑定介绍人成功',
- showCancel: false,
- success: suc => {
- uni.reLaunch({
- url: '../../../pages/order-info/order-info?order_no=' + this.order_no
- })
- }
- })
- } else {
- uni.showModal({
- content: res.data,
- showCancel: false
- })
- }
- })
- },
- //添加新用户
- addUser() {
- if (!this.userPhone) {
- uni.showModal({
- content: '请先输入手机号',
- showCancel: false
- });
- return false;
- }
- if (!this.userName) {
- uni.showModal({
- content: '请先输入昵称',
- showCancel: false
- });
- return false;
- }
- uni.showLoading({
- title: '提交中...'
- })
- addUser({
- phone: this.userPhone,
- is_vip: '',
- nickname: this.userName,
- code: this.areaCode
- }).then(res => {
- if (res.code == 200) {
- this.userInfo = res.data
- this.showPop = true
- } else {
- uni.showModal({
- content: res.data || '添加失败',
- showCancel: false
- });
- }
- uni.hideLoading()
- }).catch(() => {
- uni.hideLoading()
- })
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .pop {
- width: 100%;
- height: 100vh;
- position: fixed;
- top: 0;
- left: 0;
- background-color: rgba(0, 0, 0, 0.7);
- z-index: 9999999;
- .hint_icon {
- width: 183rpx;
- height: 135rpx;
- position: relative;
- margin-top: -85rpx;
- }
- .pop_con {
- width: 648rpx;
- height: 442rpx;
- background: #fff;
- border-radius: 26rpx;
- display: flex;
- flex-direction: column;
- // align-items: center;
- padding: 0 30rpx;
- box-sizing: border-box;
- .hint {
- width: 100%;
- text-align: center;
- .title {
- font-size: 36rpx;
- font-weight: bold;
- margin-top: 22rpx;
- }
- }
- .con {
- min-height: 120rpx;
- margin: 20rpx 0 20rpx;
- font-size: 34rpx;
- }
- .btn_box {
- width: 100%;
- view {
- width: 270rpx;
- height: 88rpx;
- background: #FFF4F3;
- border: 2rpx solid #FB231F;
- border-radius: 44rpx;
- color: $base-color;
- font-size: 32rpx;
- }
- view:last-child {
- background: $base-line-bg;
- color: #fff;
- }
- }
- }
- .iconfont {
- color: #fff;
- font-size: 60rpx;
- margin-top: 30rpx;
- }
- }
- .add {
- width: 100%;
- min-height: 100%;
- background: #fff;
- position: relative;
- .add_user {
- width: 690rpx;
- margin: 0 auto;
- padding-top: 30rpx;
- .inp_box {
- .label {
- font-size: 32rpx;
- font-weight: bold;
- padding: 30rpx 0;
- .star {
- font-size: 36rpx;
- color: $base-color;
- margin-left: 10rpx;
- }
- .hint {
- color: #999;
- }
- }
- .phone-area {
- margin-bottom: 20rpx;
- .text {
- font-size: 32rpx;
- }
- .area {
- color: #42b983;
- }
- }
- .change_box {
- flex: 1;
- margin-top: 20rpx;
- view {
- width: 330rpx;
- height: 72rpx;
- font-size: 32rpx;
- border: 2rpx solid #707070;
- border-radius: 42rpx;
- line-height: 72rpx;
- text-align: center;
- }
- .active {
- background: $base-line-bg;
- border: none;
- color: #fff;
- }
- }
- }
- input {
- width: 100%;
- background: #f9f9fb;
- height: 88rpx;
- line-height: 88rpx;
- padding-left: 15rpx;
- border-radius: 8rpx;
- }
- .sub_btn_box {
- width: 100%;
- height: 100rpx;
- background: #fff;
- position: fixed;
- bottom: 0;
- left: 0;
- border-top: 2rpx solid #eeeeee;
- .sub_btn {
- width: 690rpx;
- height: 88rpx;
- }
- }
- }
- }
- </style>
|