introduce.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view class="add">
  3. <view class="add_user">
  4. <view class="inp_box">
  5. <view class="label">
  6. <text>介绍人手机号</text>
  7. <text class="star">*</text>
  8. </view>
  9. <navigator url="../phone-area/phone-area" class="flexB phone-area">
  10. <text class="text">国家/地区</text>
  11. <view>
  12. <text class="area">{{ areaName }}({{ areaCode }})</text>
  13. <text class="iconfont iconiconfontjiantou2"></text>
  14. </view>
  15. </navigator>
  16. <input type="number" placeholder="请输入介绍人手机号" v-model="userPhone" maxlength="11" />
  17. </view>
  18. <view style="margin-top:20rpx;" class="inp_box">
  19. <view class="label">
  20. <text>介绍人昵称</text>
  21. <text class="star">*</text>
  22. </view>
  23. <input type="text" placeholder="请输入介绍人昵称" v-model="userName" />
  24. </view>
  25. <view class="sub_btn_box flexCC">
  26. <view class="sub_btn" @click="addUser">确认添加</view>
  27. </view>
  28. </view>
  29. <view class="pop flexCC" v-if="showPop">
  30. <view class="pop_con">
  31. <view class="hint">
  32. <image src="../../../static/imgs/shop/hint_icon.png" class="hint_icon"></image>
  33. <view class="title">确认信息</view>
  34. </view>
  35. <view class="con">
  36. <view>昵称:{{userInfo.nickname}}</view>
  37. <view style="margin-top:14rpx">手机号:{{userInfo.phone}}</view>
  38. </view>
  39. <view class="btn_box flexB">
  40. <view class="flexC" @click="showPop=false">取消</view>
  41. <view class="flexC" @click="toBind">确认绑定</view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. addUser,
  50. bindRecomer,
  51. getAllRecomer,
  52. editBindRecomer
  53. } from '@/apis/shop.js';
  54. export default {
  55. data() {
  56. return {
  57. userPhone: '', //新添加的用户手机号
  58. userName: '', // 新添加的用户昵称(选填)
  59. isChecked: false,
  60. notVip: true,
  61. is_vip: 0,
  62. showPop: false,
  63. order_no: '',
  64. order_id: '',
  65. remark: '',
  66. userInfo: '',
  67. areaName: '中国大陆', // 手机号地区名称
  68. areaCode: '+86', // 手机号地区代码
  69. };
  70. },
  71. onLoad(ops) {
  72. this.order_id = ops.order_id
  73. this.order_no = ops.order_no
  74. this.remark = ops.remark
  75. },
  76. created() {
  77. uni.$on('CHOOSEPHONECODE', (name, code) => { // 监听 chooseArea 事件更新
  78. this.areaName = name // 修改选择的手机号地区名称
  79. this.areaCode = code // 修改选择的手机号地区代码
  80. })
  81. },
  82. methods: {
  83. // 绑定介绍人
  84. toBind() {
  85. let http = this.remark ? editBindRecomer : bindRecomer
  86. let data = this.remark ? {
  87. id: this.userInfo.id,
  88. order_id: this.order_id,
  89. remark: this.remark
  90. } : {
  91. id: this.userInfo.id,
  92. order_id: this.order_id,
  93. }
  94. http(data).then(res => {
  95. this.showPop = false
  96. if (res.code === 200) {
  97. uni.showModal({
  98. content: this.remark ? '更换介绍人成功' : '绑定介绍人成功',
  99. showCancel: false,
  100. success: suc => {
  101. uni.reLaunch({
  102. url: '../../../pages/order-info/order-info?order_no=' + this.order_no
  103. })
  104. }
  105. })
  106. } else {
  107. uni.showModal({
  108. content: res.data,
  109. showCancel: false
  110. })
  111. }
  112. })
  113. },
  114. //添加新用户
  115. addUser() {
  116. if (!this.userPhone) {
  117. uni.showModal({
  118. content: '请先输入手机号',
  119. showCancel: false
  120. });
  121. return false;
  122. }
  123. if (!this.userName) {
  124. uni.showModal({
  125. content: '请先输入昵称',
  126. showCancel: false
  127. });
  128. return false;
  129. }
  130. uni.showLoading({
  131. title: '提交中...'
  132. })
  133. addUser({
  134. phone: this.userPhone,
  135. is_vip: '',
  136. nickname: this.userName,
  137. code: this.areaCode
  138. }).then(res => {
  139. if (res.code == 200) {
  140. this.userInfo = res.data
  141. this.showPop = true
  142. } else {
  143. uni.showModal({
  144. content: res.data || '添加失败',
  145. showCancel: false
  146. });
  147. }
  148. uni.hideLoading()
  149. }).catch(() => {
  150. uni.hideLoading()
  151. })
  152. }
  153. }
  154. };
  155. </script>
  156. <style lang="scss" scoped>
  157. .pop {
  158. width: 100%;
  159. height: 100vh;
  160. position: fixed;
  161. top: 0;
  162. left: 0;
  163. background-color: rgba(0, 0, 0, 0.7);
  164. z-index: 9999999;
  165. .hint_icon {
  166. width: 183rpx;
  167. height: 135rpx;
  168. position: relative;
  169. margin-top: -85rpx;
  170. }
  171. .pop_con {
  172. width: 648rpx;
  173. height: 442rpx;
  174. background: #fff;
  175. border-radius: 26rpx;
  176. display: flex;
  177. flex-direction: column;
  178. // align-items: center;
  179. padding: 0 30rpx;
  180. box-sizing: border-box;
  181. .hint {
  182. width: 100%;
  183. text-align: center;
  184. .title {
  185. font-size: 36rpx;
  186. font-weight: bold;
  187. margin-top: 22rpx;
  188. }
  189. }
  190. .con {
  191. min-height: 120rpx;
  192. margin: 20rpx 0 20rpx;
  193. font-size: 34rpx;
  194. }
  195. .btn_box {
  196. width: 100%;
  197. view {
  198. width: 270rpx;
  199. height: 88rpx;
  200. background: #FFF4F3;
  201. border: 2rpx solid #FB231F;
  202. border-radius: 44rpx;
  203. color: $base-color;
  204. font-size: 32rpx;
  205. }
  206. view:last-child {
  207. background: $base-line-bg;
  208. color: #fff;
  209. }
  210. }
  211. }
  212. .iconfont {
  213. color: #fff;
  214. font-size: 60rpx;
  215. margin-top: 30rpx;
  216. }
  217. }
  218. .add {
  219. width: 100%;
  220. min-height: 100%;
  221. background: #fff;
  222. position: relative;
  223. .add_user {
  224. width: 690rpx;
  225. margin: 0 auto;
  226. padding-top: 30rpx;
  227. .inp_box {
  228. .label {
  229. font-size: 32rpx;
  230. font-weight: bold;
  231. padding: 30rpx 0;
  232. .star {
  233. font-size: 36rpx;
  234. color: $base-color;
  235. margin-left: 10rpx;
  236. }
  237. .hint {
  238. color: #999;
  239. }
  240. }
  241. .phone-area {
  242. margin-bottom: 20rpx;
  243. .text {
  244. font-size: 32rpx;
  245. }
  246. .area {
  247. color: #42b983;
  248. }
  249. }
  250. .change_box {
  251. flex: 1;
  252. margin-top: 20rpx;
  253. view {
  254. width: 330rpx;
  255. height: 72rpx;
  256. font-size: 32rpx;
  257. border: 2rpx solid #707070;
  258. border-radius: 42rpx;
  259. line-height: 72rpx;
  260. text-align: center;
  261. }
  262. .active {
  263. background: $base-line-bg;
  264. border: none;
  265. color: #fff;
  266. }
  267. }
  268. }
  269. input {
  270. width: 100%;
  271. background: #f9f9fb;
  272. height: 88rpx;
  273. line-height: 88rpx;
  274. padding-left: 15rpx;
  275. border-radius: 8rpx;
  276. }
  277. .sub_btn_box {
  278. width: 100%;
  279. height: 100rpx;
  280. background: #fff;
  281. position: fixed;
  282. bottom: 0;
  283. left: 0;
  284. border-top: 2rpx solid #eeeeee;
  285. .sub_btn {
  286. width: 690rpx;
  287. height: 88rpx;
  288. }
  289. }
  290. }
  291. }
  292. </style>