shop.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="center">
  3. <view class="info">
  4. <view class="name">城攻闪拓</view>
  5. <view class="avatar">邀请你加入</view>
  6. </view>
  7. <view class="input-box"><input class="input" v-model="name" type="text" placeholder="请输入您的真实姓名" /></view>
  8. <view class="input-box"><input class="input" v-model="phone" type="text" placeholder="请输入您的电话号码" /></view>
  9. <view class="input-box"><input class="input" v-model="code" type="text" placeholder="请输入您的工号" /></view>
  10. <view class="input-box">
  11. <picker @change="bindPickerEdu" :value="zuId" :range="chooseEdu" range-key="group_name" class="box-right">
  12. <text>{{ education }}</text>
  13. </picker>
  14. </view>
  15. <view class="bottom" @click="bd()">马上加入</view>
  16. </view>
  17. </template>
  18. <script>
  19. import { mapState, mapMutations } from 'vuex';
  20. import { interceptor, saveUrl } from '@/utils/loginUtils';
  21. import { groups, setWaiter } from '@/api/coupon.js';
  22. export default {
  23. data() {
  24. return {
  25. id: '',
  26. name: '',
  27. phone: '',
  28. code: '',
  29. zuName: '',
  30. zuId: '',
  31. education: '请选择你的小组',
  32. chooseEdu: []
  33. };
  34. },
  35. computed: {
  36. ...mapState(['userInfo', 'orderInfo', 'hasLogin'])
  37. },
  38. onLoad(option) {
  39. if (!this.hasLogin) {
  40. saveUrl();
  41. interceptor();
  42. } else {
  43. this.id = option.scene;
  44. this.loadData();
  45. }
  46. },
  47. methods: {
  48. loadData() {
  49. groups({}, this.id).then(e => {
  50. // groups({}, 1).then(e => {
  51. this.chooseEdu = e.data.list;
  52. console.log(this.chooseEdu);
  53. console.log(e);
  54. });
  55. },
  56. bd() {
  57. if (this.name == '') {
  58. return this.$api.msg('请输入真实姓名');
  59. }
  60. if (this.phone == '') {
  61. return this.$api.msg('请输入电话号码');
  62. }
  63. if (this.code == '') {
  64. return this.$api.msg('请输入工号');
  65. }
  66. if (this.zuId == '') {
  67. return this.$api.msg('请选择要加入的小组');
  68. }
  69. setWaiter(
  70. {
  71. name: this.name,
  72. phone: this.phone,
  73. code: this.code,
  74. groups_id: this.zuId,
  75. fuck: this.userInfo.uid,
  76. fuck_name: 'setWaiter'
  77. },
  78. this.id
  79. ).then(e => {
  80. this.$api.msg('加入成功');
  81. setTimeout(function() {
  82. uni.switchTab({
  83. url: '/pages/index/index'
  84. });
  85. }, 1000);
  86. });
  87. },
  88. bindPickerEdu: function(e) {
  89. console.log(e, 'hhh');
  90. this.education = this.chooseEdu[e.detail.value].group_name;
  91. this.zuName = this.chooseEdu[e.detail.value].group_name;
  92. this.zuId = this.chooseEdu[e.detail.value].id;
  93. }
  94. }
  95. };
  96. </script>
  97. <style lang="scss">
  98. .info {
  99. margin: 50rpx 0 100rpx;
  100. }
  101. .name {
  102. text-align: center;
  103. font-size: 30rpx;
  104. font-family: PingFang SC;
  105. font-weight: 500;
  106. }
  107. .avatar {
  108. margin-top: 20rpx;
  109. font-size: 24rpx;
  110. font-family: PingFang SC;
  111. font-weight: 500;
  112. color: #999999;
  113. text-align: center;
  114. }
  115. .input-box {
  116. padding: 10rpx 20rpx;
  117. margin: 20rpx auto 0;
  118. border: 1px solid #999999;
  119. width: 560rpx;
  120. text-align: center;
  121. font-size: 24rpx;
  122. .input {
  123. text-align: center;
  124. font-size: 24rpx;
  125. }
  126. }
  127. .bottom {
  128. margin: 100rpx auto 0;
  129. width: 560rpx;
  130. background: linear-gradient(90deg, #fe6f61 0%, #ff4343 100%);
  131. color: #ffffff;
  132. text-align: center;
  133. padding: 26rpx 0rpx;
  134. border-radius: 50rpx;
  135. }
  136. </style>