addXcx.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="container">
  3. <form @submit="onSubmit">
  4. <view class="page-block">
  5. <view class="content">
  6. <view class="cell flex flex-y-center">
  7. <view class="title-block required">
  8. <text>名称</text>
  9. </view>
  10. <view class="desc">
  11. <input type="text" :value="info.name" name="name" class="input-box" placeholder="请输入"
  12. placeholder-class="desc-placeholder">
  13. </view>
  14. </view>
  15. <view class="cell flex flex-y-center arr-r">
  16. <view class="title-block">
  17. <text>来源</text>
  18. </view>
  19. <view class="desc">
  20. <picker mode="selector" :range="TypeList" @change="onTableTypeChange">
  21. <view>
  22. {{TypeList[TypeActive]}}
  23. </view>
  24. </picker>
  25. </view>
  26. </view>
  27. <view class="cell flex flex-y-center">
  28. <view class="title-block">
  29. <text>简介</text>
  30. </view>
  31. <view class="desc">
  32. <input type="text" :value="info.desc" name="desc" class="input-box" placeholder="请输入"
  33. placeholder-class="desc-placeholder">
  34. </view>
  35. </view>
  36. <view class="cell flex flex-y-center">
  37. <view class="title-block required">
  38. <text>appid</text>
  39. </view>
  40. <view class="desc">
  41. <input type="text" :value="info.appid" name="appid" class="input-box" placeholder="请输入"
  42. placeholder-class="desc-placeholder">
  43. </view>
  44. </view>
  45. <view class="cell flex flex-y-center">
  46. <view class="title-block">
  47. <text>跳转路径</text>
  48. </view>
  49. <view class="desc">
  50. <input type="text" :value="info.pages" name="pages" class="input-box" placeholder="请输入"
  51. placeholder-class="desc-placeholder">
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view style="height: 150rpx;"></view>
  57. <view class="footer-bar">
  58. <view class="content flex flex-center" style="background: none;">
  59. <button hover-class="none" class="btn" form-type="submit">
  60. {{id?'保存':'立即添加'}}
  61. </button>
  62. </view>
  63. </view>
  64. </form>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. admin_id: "",
  72. id: "",
  73. TypeList: [
  74. "微信",
  75. "支付宝",
  76. ],
  77. TypeActive: 0,
  78. table_type_id: "",
  79. info:{},
  80. }
  81. },
  82. onLoad(options) {
  83. this.admin_id = uni.getStorageSync('admin_id')
  84. if (options.id) {
  85. this.id = options.id;
  86. this.applet_info()
  87. }
  88. },
  89. methods: {
  90. onTableTypeChange(e) {
  91. this.TypeActive = e.detail.value
  92. },
  93. //获取桌台分类
  94. applet_info() {
  95. this.request({
  96. url: 'Smdcshop/applet_info',
  97. data: {
  98. id: this.id
  99. }
  100. }).then(res => {
  101. if (res.code == '200' || res.code == 200) {
  102. this.info = res.data
  103. this.TypeActive = Number(res.data.type-1);
  104. }
  105. })
  106. },
  107. onSubmit(e) {
  108. let detail=e.detail.value;
  109. if (!detail.name) {
  110. uni.showToast({
  111. title: "请输入名称",
  112. icon: 'none'
  113. })
  114. return false
  115. }
  116. if (!detail.appid) {
  117. uni.showToast({
  118. title: "请输入appid",
  119. icon: 'none'
  120. })
  121. return false
  122. }
  123. detail.admin_id = this.admin_id;
  124. detail.type= Number(this.TypeActive)+1;
  125. if (this.id) {
  126. detail.id = this.id;
  127. }
  128. this.request({
  129. url: this.id?'Smdcshop/applet_update':'Smdcshop/applet_add',
  130. data: detail
  131. }).then(res => {
  132. if (res.code == 200) {
  133. uni.showModal({
  134. content: this.table_id ? '编辑成功' : '添加成功',
  135. showCancel: false,
  136. success: (r) => {
  137. uni.navigateBack();
  138. }
  139. })
  140. }
  141. })
  142. },
  143. }
  144. }
  145. </script>
  146. <style>
  147. @import url("../static/css/common.css");
  148. page {
  149. background-color: #F4F5F7;
  150. }
  151. </style>