addstorenumber.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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">
  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 class="cell flex flex-y-center">
  23. <view class="title-block required">
  24. <text>真实姓名</text>
  25. </view>
  26. <view class="desc">
  27. <input type="text" :value="info.nickname" name="nickname" class="input-box" placeholder="请输入"
  28. placeholder-class="desc-placeholder">
  29. </view>
  30. </view>
  31. <view class="cell flex flex-y-center">
  32. <view class="title-block required">
  33. <text>登录账号</text>
  34. </view>
  35. <view class="desc">
  36. <input type="text" :value="info.name" name="name" class="input-box" placeholder="请输入"
  37. placeholder-class="desc-placeholder">
  38. </view>
  39. </view>
  40. <view class="cell flex flex-y-center">
  41. <view class="title-block required">
  42. <text>登录密码</text>
  43. </view>
  44. <view class="desc">
  45. <input type="text" name="password" class="input-box" placeholder="请输入"
  46. placeholder-class="desc-placeholder">
  47. </view>
  48. </view>
  49. <view class="cell flex flex-y-center">
  50. <view class="title-block required">
  51. <text>确认密码</text>
  52. </view>
  53. <view class="desc">
  54. <input type="text" name="password2" class="input-box" placeholder="请输入"
  55. placeholder-class="desc-placeholder">
  56. </view>
  57. </view>
  58. </view>
  59. <!-- <view class="info-car">
  60. <view class="title-block">
  61. <view class="title">
  62. 请上传LOGO
  63. </view>
  64. </view>
  65. <view class="content" @click="ChooseImage">
  66. <image :src="thumb?URL+thumb:'../static/images/icon_6.png'" class="logo-img"
  67. mode="">
  68. </image>
  69. </view>
  70. </view>
  71. -->
  72. </view>
  73. <view class="footer-bar">
  74. <view class="content flex flex-center" style="background: none;position: relative;">
  75. <button class="btn" hover-class="none" form-type="submit">
  76. 立即提交
  77. </button>
  78. </view>
  79. </view>
  80. </form>
  81. </view>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. URL:getApp().globalData.URL,
  88. tableTypeList: [],
  89. tableTypeActive: "请选择",
  90. store_id: "",
  91. imgid: "",
  92. admin_id: "",
  93. id: "",
  94. info: {},thumb:"",
  95. }
  96. },
  97. onLoad(options) {
  98. this.admin_id = uni.getStorageSync("admin_id");
  99. this.shop_store_index();
  100. if (options.id) {
  101. this.id = options.id;
  102. }
  103. },
  104. methods: {
  105. onTableTypeChange(e) {
  106. console.log(e)
  107. this.tableTypeActive = this.tableTypeList[e.detail.value].title;
  108. this.store_id = this.tableTypeList[e.detail.value].id
  109. },
  110. ChooseImage(e) {
  111. let type = e.currentTarget.dataset.type;
  112. uni.chooseImage({
  113. count: 1, //默认9
  114. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  115. sourceType: ['album'], //从相册选择
  116. success: (res) => {
  117. console.log(res)
  118. res.tempFilePaths.forEach((v, i) => {
  119. this.Upload({
  120. url: "Smdcshop/upload",
  121. data: {
  122. url: v,
  123. type: "",
  124. token: "",
  125. admin_id: this.admin_id
  126. }
  127. }).then(res => {
  128. console.log(res, "res")
  129. this.imgid = res.id;
  130. this.thumb = res.src;
  131. }).catch(err => {
  132. uni.showToast({
  133. title: err.message,
  134. icon: 'none'
  135. })
  136. });
  137. })
  138. },
  139. });
  140. },
  141. shop_store_index() {
  142. this.request({
  143. url: 'Smdcshop/shop_store_index',
  144. data: {
  145. admin_id: this.admin_id,
  146. }
  147. }).then(res => {
  148. if (res.code == 200) {
  149. this.tableTypeList = res.data
  150. if(this.id){
  151. this.store_user_info(this.id);
  152. }
  153. }
  154. })
  155. },
  156. //获取详情
  157. store_user_info(id) {
  158. this.request({
  159. url: 'Smdcshop/store_user_info',
  160. data: {
  161. id: id
  162. }
  163. }).then(res => {
  164. if (res.code=="200") {
  165. console.log(res.data,this.tableTypeList,"res.data")
  166. this.info = res.data;
  167. this.thumb=res.data.thumb;
  168. for(let i of this.tableTypeList){
  169. console.log(i.id,res.data.store_id)
  170. if(i.id==res.data.store_id){
  171. console.log(i.title)
  172. this.tableTypeActive=i.title;
  173. }
  174. }
  175. this.store_id=res.data.store_id;
  176. }
  177. })
  178. },
  179. onSubmit(e) {
  180. let params = {
  181. store_id: this.store_id,
  182. admin_id: this.admin_id,
  183. thumb: this.imgid,
  184. },url,
  185. data = Object.assign(params, e.detail.value);
  186. console.log(data, "password")
  187. if (data.name == "") {
  188. uni.showToast({
  189. title: "请输入账号",
  190. icon: 'none'
  191. })
  192. return false
  193. } else if (!data.store_id) {
  194. uni.showToast({
  195. title: "请选择门店",
  196. icon: 'none'
  197. })
  198. return false
  199. } else if (!data.password) {
  200. uni.showToast({
  201. title: "请输入密码",
  202. icon: 'none'
  203. })
  204. return false
  205. }
  206. if (this.id) {
  207. //修改
  208. data.id = this.id;
  209. url = 'Smdcshop/store_user_update';
  210. } else {
  211. //新增
  212. url = 'Smdcshop/store_user_add';
  213. }
  214. this.request({
  215. url: url,
  216. data: data,
  217. }).then(res => {
  218. if (res.code == 200) {
  219. uni.showToast({
  220. title: res.message,
  221. icon: 'none'
  222. })
  223. setTimeout(() => {
  224. uni.navigateBack()
  225. }, 2000)
  226. }
  227. }).catch((res) => {
  228. uni.showToast({
  229. title: res.message,
  230. icon: 'none'
  231. })
  232. });
  233. },
  234. }
  235. }
  236. </script>
  237. <style>
  238. @import url("../static/css/common.css");
  239. page {
  240. background-color: #F4F5F7;
  241. }
  242. .info-car {
  243. margin-top: 25rpx;
  244. background-color: #fff;
  245. padding: 0 25rpx;
  246. }
  247. .info-car .title-block {
  248. border-bottom: 1rpx solid #f5f5f5;
  249. }
  250. .info-car .title {
  251. height: 100rpx;
  252. line-height: 100rpx;
  253. font-size: 30rpx;
  254. color: #333;
  255. font-weight: 600;
  256. }
  257. .info-car .content {
  258. padding: 30rpx 0;
  259. }
  260. .info-car .input-box {
  261. font-size: 28rpx;
  262. color: #000;
  263. }
  264. .info-car .logo-img {
  265. display: block;
  266. width: 120rpx;
  267. height: 120rpx;
  268. }
  269. </style>