hornAdd.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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 arr-r" 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 class="cell flex flex-y-center arr-r">
  23. <view class="title-block required">
  24. <text>设备类型</text>
  25. </view>
  26. <view class="desc">
  27. <picker mode="selector" :range="printerAddrList" @change="onPrinterAddrChange">
  28. <view :class="[printerAddr?'':'desc-placeholder','input-box']">{{printerAddr || '请选择'}}
  29. </view>
  30. </picker>
  31. </view>
  32. </view>
  33. <view class="cell flex flex-y-center">
  34. <view class="title-block required">
  35. <text>设备号</text>
  36. </view>
  37. <view class="desc">
  38. <input type="num" v-model="detail.device_id" name="device_id" class="input-box"
  39. placeholder="请输入" placeholder-class="desc-placeholder">
  40. </view>
  41. <image src="@/static/images/saoma.png" mode="aspectFit" class="icon-saoma" @click="getDeviceId"></image>
  42. </view>
  43. <view class="cell flex flex-y-center">
  44. <view class="title-block requsired">
  45. <text>播报方式</text>
  46. </view>
  47. <view class="desc">
  48. <view class="flex-center">
  49. <view class="checklist-box " @click="choicepay(item.type)"
  50. v-for="(item,index) of integral_arr" :key='index'
  51. :class="is_integral==item.type?'actt':''">
  52. <view class="radio__inner" :class="is_integral==item.type?'act_border':''">
  53. <view :class="is_integral==item.type?'is-default-checked':''"
  54. class="radio__inner-icon radio__inner-icon ">
  55. </view>
  56. </view>
  57. <text class="checklist-text">{{item.name}}</text>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <block v-if="device_type==3">
  63. <!-- <view class="cell flex flex-y-center">
  64. <view class="title-block required">
  65. <text>友商编号</text>
  66. </view>
  67. <view class="desc">
  68. <input type="text" :value="detail.agent_id" name="agent_id" class="input-box"
  69. placeholder="请输入友商编号" placeholder-class="desc-placeholder">
  70. </view>
  71. </view> -->
  72. <!-- <view class="cell flex flex-y-center">
  73. <view class="title-block required">
  74. <text>友商接入密钥</text>
  75. </view>
  76. <view class="desc">
  77. <input type="text" :value="detail.agent_secret" name="agent_secret" class="input-box"
  78. placeholder="请输入友商接入密钥" placeholder-class="desc-placeholder">
  79. </view>
  80. </view> -->
  81. <!-- <view class="cell flex flex-y-center">
  82. <view class="title-block required">
  83. <text>音箱编号</text>
  84. </view>
  85. <view class="desc">
  86. <input type="text" :value="detail.sbx_id" name="sbx_id" class="input-box"
  87. placeholder="请输入音箱编号" placeholder-class="desc-placeholder">
  88. </view>
  89. </view>
  90. -->
  91. <view class="cell flex flex-y-center">
  92. <view class="title-block required">
  93. <text>消息密钥</text>
  94. </view>
  95. <view class="desc">
  96. <input type="text" :value="detail.msg_token" name="msg_token" class="input-box"
  97. placeholder="请输入消息密钥" placeholder-class="desc-placeholder">
  98. </view>
  99. </view>
  100. </block>
  101. <view class="cell flex flex-y-center">
  102. <view class="title-block requsired">
  103. <text>排序</text>
  104. </view>
  105. <view class="desc">
  106. <input type="num" :value="detail.num" class="input-box" placeholder="请输入"
  107. placeholder-class="desc-placeholder">
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. <view class="footer-bar">
  113. <view class="content flex flex-center" style="background: none;">
  114. <button class="btn" hover-class="none" form-type="submit">
  115. {{info.id?'修改':'添加'}}
  116. </button>
  117. </view>
  118. </view>
  119. </form>
  120. </view>
  121. </template>
  122. <script>
  123. export default {
  124. data() {
  125. return {
  126. tableTypeList: [],
  127. tableTypeActive: "请选择",
  128. printerAddrList: ['品生', '品生(新)', '百励华','百励华-WiFi' ],
  129. printerAddr: '品生',
  130. device_type: 1,
  131. tableType: "",
  132. admin_id: "",
  133. info: {},
  134. detail: {
  135. device_id:''
  136. },
  137. integral_arr: [{
  138. type: 1,
  139. name: "收款播报",
  140. }, {
  141. type: 2,
  142. name: "排队播报(只支持品生新)",
  143. }, ],
  144. is_integral: 1,
  145. type: 2,
  146. store_id: "",
  147. }
  148. },
  149. onLoad(e) {
  150. if (e.id) {
  151. this.info = e;
  152. this.details();
  153. uni.setNavigationBarTitle({
  154. title: "设置云喇叭"
  155. })
  156. }
  157. this.type = e.type || 2;
  158. this.admin_id = uni.getStorageSync("admin_id");
  159. if (e.type == 1) {
  160. this.shop_store_index();
  161. } else {
  162. this.store_id = uni.getStorageSync("store_id");
  163. }
  164. },
  165. methods: {
  166. getDeviceId(){
  167. uni.scanCode({
  168. success:res=>{
  169. console.log(res)
  170. this.$set(this.detail,'device_id',res.result)
  171. }
  172. })
  173. },
  174. shop_store_index() {
  175. this.request({
  176. url: 'Smdcshop/shop_store_index',
  177. data: {
  178. admin_id: this.admin_id,
  179. }
  180. }).then(res => {
  181. if (res.code == 200) {
  182. this.tableTypeList = res.data
  183. }
  184. })
  185. },
  186. onTableTypeChange(e) {
  187. this.tableTypeActive = this.tableTypeList[e.detail.value].title;
  188. this.store_id = this.tableTypeList[e.detail.value].id
  189. },
  190. choicepay(index) {
  191. this.is_integral = index;
  192. },
  193. details() {
  194. this.request({
  195. url: 'Smdcshop/horn_info',
  196. data: {
  197. id: this.info.id
  198. }
  199. }).then(res => {
  200. if (res.code == 200) {
  201. this.detail = res.data;
  202. this.printerAddr = res.data.device_type == 1 ? '品生' :res.data.device_type == 2 ? '品生(新)':res.data.device_type == 3 ?'百励华':res.data.device_type == 4?'百励华-WiFi':'';
  203. this.device_type = res.data.device_type;
  204. this.is_integral = res.data.type;
  205. }
  206. })
  207. },
  208. onPrinterAddrChange(e) {
  209. this.printerAddr = this.printerAddrList[e.detail.value];
  210. this.device_type = Number(e.detail.value) + 1;
  211. },
  212. onSubmit(e) {
  213. let params = {
  214. store_id: this.store_id,
  215. device_type: this.device_type,
  216. device_id: e.detail.value.device_id,
  217. num: e.detail.value.num,
  218. admin_id: this.admin_id,
  219. type: this.is_integral,
  220. msg_token:e.detail.value.msg_token
  221. },
  222. url;
  223. if (this.info.id) {
  224. params.id = this.info.id
  225. url = "Smdcshop/horn_update"
  226. } else {
  227. url = 'Smdcshop/horn_add'
  228. }
  229. if (!params.store_id) {
  230. uni.showToast({
  231. title: "请选择门店",
  232. icon: 'none'
  233. })
  234. return false
  235. }
  236. if (!params.device_id) {
  237. uni.showToast({
  238. title: "必选不能为空",
  239. icon: 'none'
  240. })
  241. return false
  242. }
  243. this.request({
  244. url,
  245. data: params
  246. }).then(res => {
  247. if (res.code == 200) {
  248. uni.showToast({
  249. title: res.message,
  250. icon: 'none'
  251. })
  252. setTimeout(() => {
  253. uni.navigateBack()
  254. }, 2000)
  255. }
  256. }).catch((res) => {
  257. uni.showToast({
  258. title: res.message,
  259. icon: 'none'
  260. })
  261. });
  262. },
  263. }
  264. }
  265. </script>
  266. <style>
  267. @import url("./static/css/common.css");
  268. page {
  269. background-color: #F4F5F7;
  270. }
  271. .checklist-box {
  272. display: -webkit-box;
  273. display: -webkit-flex;
  274. display: flex;
  275. -webkit-box-orient: horizontal;
  276. -webkit-box-direction: normal;
  277. -webkit-flex-direction: row;
  278. flex-direction: row;
  279. -webkit-box-align: center;
  280. -webkit-align-items: center;
  281. align-items: center;
  282. margin: 5px 0;
  283. margin-right: 22px;
  284. }
  285. .radio__inner {
  286. -webkit-flex-shrink: 0;
  287. flex-shrink: 0;
  288. display: -webkit-box;
  289. display: -webkit-flex;
  290. display: flex;
  291. -webkit-box-pack: center;
  292. -webkit-justify-content: center;
  293. justify-content: center;
  294. -webkit-box-align: center;
  295. -webkit-align-items: center;
  296. align-items: center;
  297. position: relative;
  298. border: 1px solid #DCDFE6;
  299. border-radius: 2px;
  300. box-sizing: border-box;
  301. width: 16px;
  302. height: 16px;
  303. border-radius: 16px;
  304. background-color: #fff;
  305. z-index: 1;
  306. -webkit-transition: border-color .3s;
  307. transition: border-color .3s;
  308. }
  309. .radio__inner-icon {
  310. width: 8px;
  311. height: 8px;
  312. border-radius: 10px;
  313. opacity: 0;
  314. -webkit-transition: -webkit-transform .3s;
  315. transition: -webkit-transform .3s;
  316. transition: transform .3s;
  317. transition: transform .3s, -webkit-transform .3s;
  318. }
  319. .is-default-checked {
  320. opacity: 1;
  321. background-color: #007aff;
  322. -webkit-transform: rotate(45deg) scaleY(1);
  323. transform: rotate(45deg) scaleY(1);
  324. }
  325. .checklist-text {
  326. font-size: 28rpx;
  327. margin-left: 5px;
  328. -webkit-transition: color 0.2s;
  329. transition: color 0.2s;
  330. color: #000;
  331. }
  332. .act_border {
  333. border: 1rpx solid #007aff;
  334. }
  335. .icon-saoma{
  336. display: block;
  337. width: 48rpx;
  338. height: 48rpx;
  339. }
  340. </style>