giveFamilyCard.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="box">
  3. <u--form labelPosition="top" :model="form" :rules="rules" ref="uForm">
  4. <u-form-item labelWidth="auto" label="被赠送会员编号" prop="memberNo">
  5. <u-input v-model="form.memberNo" placeholder="请输入被赠送会员编号" border="bottom">
  6. <u-text text="Vip." color="#000000" slot="prefix" margin="0 3px 0 0" type="tips"></u-text>
  7. </u-input>
  8. </u-form-item>
  9. <u-form-item labelWidth="auto" label="被赠送会员手机号" prop="memberPhone">
  10. <u-input v-model="form.memberPhone" placeholder="请输入被赠送会员手机号" border="bottom"
  11. ></u-input>
  12. </u-form-item>
  13. </u--form>
  14. <view class="op-btn-wrap">
  15. <view class="h-btn" @click="handleGive">
  16. <text>确定
  17. <text class="presentCount" v-if="count !== null">(剩余可赠送{{count}}次)</text>
  18. </text>
  19. </view>
  20. <view class="h-btn1" @click="handleGive">
  21. <text>确定
  22. <text class="presentCount" v-if="count !== null">(剩余可赠送{{count}}次)</text>
  23. </text>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name: "giveFamilyCard",
  31. data() {
  32. return {
  33. form: {
  34. memberNo:'',
  35. memberPhone:''
  36. },
  37. count:null,
  38. rules: {
  39. 'memberNo': {
  40. type: 'string',
  41. required: true,
  42. min: 8,
  43. max: 10,
  44. message: '请输入6-18位密码',
  45. trigger: ['blur', 'change']
  46. },
  47. 'memberPhone': {
  48. type: 'string',
  49. required: true,
  50. min: 11,
  51. max: 11,
  52. pattern:this.$phonePattern,
  53. message: '请输入正确的电话号码',
  54. trigger: ['blur', 'change']
  55. },
  56. }
  57. }
  58. },
  59. onShow(){
  60. this.presentCount()
  61. },
  62. methods: {
  63. handleGive() {
  64. if (this.count == 0){
  65. uni.$u.toast('可赠送次数不足!')
  66. return
  67. }
  68. this.$refs.uForm.validate().then(res=>{
  69. let data={
  70. memberNo:"Vip." + this.form.memberNo,
  71. memberPhone:this.form.memberPhone
  72. }
  73. this.$api.giveFamilyCard(data).then((res) => {
  74. console.log(res)
  75. uni.showToast({
  76. duration: 2000,
  77. title: '赠送成功'
  78. });
  79. uni.navigateBack({delta : 1})
  80. }
  81. )
  82. })
  83. },
  84. presentCount(){
  85. this.$api.presentCount().then(res=>{
  86. this.count = res.data.data
  87. })
  88. }
  89. }
  90. }
  91. </script>
  92. <style scoped>
  93. .box {
  94. padding: 24rpx 32rpx;
  95. }
  96. .h-btn1 {
  97. margin: 48rpx auto;
  98. text-align: center;
  99. width: 686rpx;
  100. height: 84rpx;
  101. background: #FFE05C;
  102. border-radius: 50rpx;
  103. line-height: 84rpx;
  104. }
  105. .h-btn {
  106. margin: 48rpx auto;
  107. text-align: center;
  108. width: 343px;
  109. height: 42px;
  110. background: #FFE05C;
  111. border-radius: 27px;
  112. line-height: 42px;
  113. }
  114. .presentCount{
  115. font-size: 24rpx;
  116. line-height: 84rpx;
  117. color: #666666;
  118. }
  119. /deep/ .u-text__value--tips{
  120. color: #333333 !important;
  121. }
  122. </style>