add.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="container">
  3. <form @submit="onSubmit">
  4. <view class="page-block">
  5. <view class="page-title-block">
  6. <view class="title">设备信息</view>
  7. </view>
  8. <view class="content">
  9. <view class="cell flex flex-y-center" v-if="type==1">
  10. <view class="title-block required">
  11. <text>所属门店</text>
  12. </view>
  13. <view class="desc">
  14. <picker mode="selector" :range="tableTypeList" range-key="title"
  15. @change="onTableTypeChange">
  16. <view>
  17. {{tableTypeActive}}
  18. </view>
  19. </picker>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="content">
  24. <view class="cell flex flex-y-center">
  25. <view class="title-block required">
  26. <text>终端号</text>
  27. </view>
  28. <view class="desc">
  29. <input type="text" :value="info.device_sn" name="device_sn" class="input-box"
  30. placeholder="请输入终端号" placeholder-class="desc-placeholder">
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="footer-bar">
  36. <view class="content flex flex-center" style="background: none;">
  37. <button class="btn" hover-class="none" form-type="submit">
  38. 立即添加
  39. </button>
  40. </view>
  41. </view>
  42. </form>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. store_id: "",
  50. tableTypeList: [],
  51. tableTypeActive: "请选择",
  52. admin_id: '',
  53. type: 2
  54. }
  55. },
  56. onLoad(e) {
  57. this.type = e.type || 2;
  58. this.admin_id = uni.getStorageSync("admin_id");
  59. this.store_id = uni.getStorageSync("store_id");
  60. if (e.type == 1) {
  61. this.shop_store_index();
  62. }
  63. },
  64. methods: {
  65. shop_store_index() {
  66. this.request({
  67. url: 'Smdcshop/shop_store_index',
  68. data: {
  69. admin_id: this.admin_id,
  70. }
  71. }).then(res => {
  72. if (res.code == 200) {
  73. this.tableTypeList = res.data
  74. }
  75. })
  76. },
  77. onTableTypeChange(e) {
  78. this.tableTypeActive = this.tableTypeList[e.detail.value].title;
  79. this.store_id = this.tableTypeList[e.detail.value].id
  80. },
  81. onSubmit(e) {
  82. if (e.detail.value.device_sn == "") {
  83. uni.showToast({
  84. title: "请输入设备号",
  85. icon: 'none'
  86. })
  87. return false
  88. }
  89. this.request({
  90. url: 'Litepay/ListAdd',
  91. data: {
  92. store_id: this.store_id,
  93. device_sn: e.detail.value.device_sn,
  94. type: 2,
  95. },
  96. is_agent: "admin",
  97. }).then(res => {
  98. if (res.code == 200) {
  99. uni.showToast({
  100. title: res.msg,
  101. icon: 'none'
  102. })
  103. setTimeout(() => {
  104. uni.navigateBack()
  105. }, 2000)
  106. }
  107. }).catch((res) => {
  108. uni.showToast({
  109. title: res.msg,
  110. icon: 'none'
  111. })
  112. });
  113. },
  114. }
  115. }
  116. </script>
  117. <style>
  118. @import url("../../static/css/common.css");
  119. page {
  120. background-color: #F4F5F7;
  121. }
  122. </style>