index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view class="page">
  3. <navBar title="新增兑奖记录" :back="true" color="black" background="white" />
  4. <view class="content">
  5. <view class="item">
  6. <view class="label">
  7. *姓名
  8. </view>
  9. <u--input clearable placeholder="请输入姓名" border="surround" v-model="name" @change="change"></u--input>
  10. </view>
  11. <view class="item">
  12. <view class="label">
  13. *电话
  14. </view>
  15. <u--input clearable placeholder="请输入电话" border="surround" v-model="phone" @change="change"></u--input>
  16. </view>
  17. <view class="item">
  18. <view class="label">
  19. *来源
  20. </view>
  21. <uni-data-select placeholder="请选择来源" v-model="source" :localdata="range"></uni-data-select>
  22. </view>
  23. <view class="item" style="margin-bottom: 24rpx;height: auto;">
  24. <view class="label">
  25. 兑奖信息
  26. </view>
  27. <u--textarea v-model="award_content" placeholder="请输入兑奖信息"></u--textarea>
  28. </view>
  29. <button class="orderBtn" :plain="true" @click="postRecord">
  30. 新增
  31. </button>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. getUserPhone,
  38. addAward
  39. } from '@/api/test/index.js'
  40. export default {
  41. components: {
  42. },
  43. data() {
  44. return {
  45. phone: '',
  46. name: '',
  47. type: 3,
  48. source: -1,
  49. status: '产业电工',
  50. award_content: '',
  51. user_id: null,
  52. range: [{
  53. value: 0,
  54. text: "兑奖"
  55. },
  56. {
  57. value: 1,
  58. text: "到店"
  59. },
  60. {
  61. value: 2,
  62. text: "朋友"
  63. },
  64. {
  65. value: 3,
  66. text: "其他"
  67. },
  68. ],
  69. }
  70. },
  71. async onLoad(options) {
  72. },
  73. methods: {
  74. async postRecord() {
  75. let parms = {}
  76. let phoneReg = /^[1][3,4,5,7,8,9][0-9]{9}$/
  77. if (!this.name) {
  78. return this.$toast('请输入姓名')
  79. }
  80. if (!this.phone) {
  81. return this.$toast('请输入电话')
  82. }
  83. if (!phoneReg.test(this.phone)) {
  84. return this.$toast('手机号格式不正确')
  85. }
  86. if (this.source == -1) {
  87. return this.$toast('请选择来源')
  88. }
  89. uni.showLoading({
  90. title: '提交中'
  91. })
  92. let res = await getUserPhone({
  93. phone: this.phone,
  94. })
  95. if (res.code == 0) {
  96. console.log('getUserPhone返回值', res.data.id);
  97. parms = {
  98. type: this.type,
  99. name: this.name,
  100. phone: this.phone,
  101. // status: this.d_ly == 0 ? '兑奖' : this.d_ly == 1 ? '到店' : this.d_ly == 2 ? '朋友' : '其他',
  102. source: this.source + 1,
  103. status: '产业电工',
  104. award_content: this.award_content,
  105. user_id: res.data.id
  106. }
  107. console.log('addAward--parmas', parms);
  108. let res1 = await addAward(parms)
  109. if (res1.code == 0) {
  110. uni.hideLoading()
  111. console.log('addAward返回值', res1);
  112. this.$toast('新增成功')
  113. setTimeout(() => {
  114. uni.navigateBack()
  115. }, 1500)
  116. } else {
  117. uni.hideLoading()
  118. uni.showToast({
  119. title: res1.message,
  120. icon: 'none'
  121. })
  122. }
  123. } else {
  124. uni.hideLoading()
  125. uni.showToast({
  126. // title:res1.msg,
  127. title: "电话号码不正确,没有查找到相应的人员",
  128. icon: 'none',
  129. duration: 3000
  130. })
  131. }
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. @import "./index.scss";
  138. </style>