giveFamilyCard.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. name: "giveFamilyCard",
  26. data() {
  27. return {
  28. form: {
  29. memberNo:'',
  30. memberPhone:''
  31. },
  32. count:null,
  33. rules: {
  34. 'memberNo': {
  35. type: 'string',
  36. required: true,
  37. min: 8,
  38. max: 10,
  39. message: '请输入6-18位密码',
  40. trigger: ['blur', 'change']
  41. },
  42. 'memberPhone': {
  43. type: 'string',
  44. required: true,
  45. min: 11,
  46. max: 11,
  47. pattern:this.$phonePattern,
  48. message: '请输入正确的电话号码',
  49. trigger: ['blur', 'change']
  50. },
  51. }
  52. }
  53. },
  54. onShow(){
  55. this.presentCount()
  56. },
  57. methods: {
  58. handleGive() {
  59. if (this.count == 0){
  60. uni.$u.toast('可赠送次数不足!')
  61. return
  62. }
  63. this.$refs.uForm.validate().then(res=>{
  64. let data={
  65. memberNo:"Vip." + this.form.memberNo,
  66. memberPhone:this.form.memberPhone
  67. }
  68. this.$api.giveFamilyCard(data).then((res) => {
  69. console.log(res)
  70. uni.showToast({
  71. duration: 2000,
  72. title: '赠送成功'
  73. });
  74. uni.navigateBack({delta : 1})
  75. }
  76. )
  77. })
  78. },
  79. presentCount(){
  80. this.$api.presentCount().then(res=>{
  81. this.count = res.data.data
  82. })
  83. }
  84. }
  85. }
  86. </script>
  87. <style scoped>
  88. .box {
  89. padding: 24rpx 32rpx;
  90. }
  91. .h-btn {
  92. margin: 48rpx auto;
  93. text-align: center;
  94. width: 686rpx;
  95. height: 84rpx;
  96. background: #FFE05C;
  97. border-radius: 50rpx;
  98. line-height: 84rpx;
  99. }
  100. .presentCount{
  101. font-size: 24rpx;
  102. line-height: 84rpx;
  103. color: #666666;
  104. }
  105. /deep/ .u-text__value--tips{
  106. color: #333333 !important;
  107. }
  108. </style>