setting.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="setting-page">
  3. <scroll-view scroll-y class="scroll-content">
  4. <view class="cell">
  5. <view class="label">自动接单</view>
  6. <view class="value">
  7. <!-- <u-switch v-model="autoTake" size="22" class="switch"></u-switch> -->
  8. <switch :checked="autoTaking" @change="handAutoTakingChange" color="#007AFF" class="switch" style="transform:scale(0.7)"></switch>
  9. </view>
  10. </view>
  11. <view class="cell">
  12. <view class="label">食品安全档案</view>
  13. <view class="value" @click="goToSafetyArchives">
  14. <u-icon name="arrow-right" size="22" color="#6c6c6c"></u-icon>
  15. </view>
  16. </view>
  17. <view class="cell">
  18. <view class="label">修改密码</view>
  19. <view class="value" @click="goToUpdatePwd">
  20. <u-icon name="arrow-right" size="22" color="#6c6c6c"></u-icon>
  21. </view>
  22. </view>
  23. </scroll-view>
  24. <view class="footer-btn">
  25. <view class="logout" @click="showModalDialog">
  26. 退出登录
  27. </view>
  28. </view>
  29. <u-modal :show="formVisible" :title="modalTitle" closeOnClickOverlay showCancelButton @confirm="updatePwd"
  30. @cancel="cancelUpdate" @close="cancelUpdate">
  31. <view class="container">
  32. <view class="name">
  33. <u-input border v-model="formItem.oldPwd" password placeholder="请输入原密码"></u-input>
  34. </view>
  35. <view></view>
  36. <view class="name">
  37. <u-input border v-model="formItem.newPwd1" password placeholder="请输入新密码"></u-input>
  38. </view>
  39. <view></view>
  40. <view class="name">
  41. <u-input border v-model="formItem.newPwd2" password placeholder="请确认新密码"></u-input>
  42. </view>
  43. </view>
  44. </u-modal>
  45. <!-- <u-modal show-cancel-button :show="quitShow" @confirm="confirm" :confirm-color="lightColor" @close="closeMo" @cancel="closeMo"
  46. :content="'确定要退出登录么?'"></u-modal> -->
  47. </view>
  48. </template>
  49. <script>
  50. import {mapState} from 'vuex';
  51. export default {
  52. data () {
  53. return {
  54. updateUrl: '/storeOrderApi/updateStoreAutoGo',
  55. autoGoUrl: '/storeOrderApi/getStoreAutoGo',
  56. updatePwdUrl: '/storeUserLoginApi/updatePwd',
  57. autoTaking: false,
  58. quitShow: false,
  59. formItem: {},
  60. formVisible: false,
  61. modalTitle: '修改密码'
  62. }
  63. },
  64. computed: {
  65. ...mapState(['storeInfo'])
  66. },
  67. methods: {
  68. getStoreAutoGo() {
  69. uni.showLoading({
  70. title: '加载中'
  71. });
  72. var dateStr = (new Date()).getTime();
  73. var sign = this.getSign(dateStr);
  74. this.requst({
  75. url: this.autoGoUrl,
  76. data: {
  77. timestamp: dateStr,
  78. sign: sign,
  79. storeId: this.storeInfo.storeId
  80. },
  81. success: res => {
  82. if (res.data.rtnBean.rtnCode == 0) {
  83. uni.hideLoading();
  84. this.autoTaking = res.data.obj.autoGo;
  85. } else {
  86. uni.hideLoading();
  87. if (res.data.rtnBean.rtnMsg != '') {
  88. this.$api.msg(res.data.rtnBean.rtnMsg);
  89. return;
  90. }
  91. }
  92. },
  93. fail: (e) => {
  94. console.log("接口调用失败:" + JSON.stringify(e));
  95. uni.hideLoading();
  96. },
  97. });
  98. },
  99. // 自动接单切换
  100. handAutoTakingChange (e) {
  101. uni.showLoading({
  102. title: '加载中'
  103. });
  104. this.autoTaking = e.detail.value
  105. var dateStr = (new Date()).getTime();
  106. var sign = this.getSign(dateStr);
  107. this.requst({
  108. url: this.updateUrl,
  109. data: {
  110. timestamp: dateStr,
  111. sign: sign,
  112. storeId: this.storeInfo.storeId,
  113. autoGo: this.autoTaking ? 1 : 0
  114. },
  115. success: res => {
  116. uni.hideLoading();
  117. },
  118. fail: (e) => {
  119. console.log("接口调用失败:" + JSON.stringify(e));
  120. uni.hideLoading();
  121. },
  122. });
  123. },
  124. /**
  125. * 显示退出登录对话框
  126. */
  127. showModalDialog() {
  128. let that = this
  129. uni.showModal({
  130. title: '提示',
  131. content: '是否确认退出?',
  132. success: function (r) {
  133. if (r.confirm) {
  134. that.confirm()
  135. } else if (r.cancel) {
  136. console.log('用户点击取消');
  137. }
  138. }
  139. });
  140. // this.quitShow = true;
  141. },
  142. goToSafetyArchives () {
  143. uni.navigateTo({
  144. url: '/pages/tools/safety-archives'
  145. })
  146. },
  147. goToUpdatePwd () {
  148. this.formVisible = true
  149. },
  150. closeMo () {
  151. this.quitShow = false
  152. },
  153. updatePwd() {
  154. if (!this.formItem.oldPwd) {
  155. uni.showToast({
  156. title: '请输入原密码',
  157. icon: 'none'
  158. })
  159. return
  160. }
  161. if (!this.formItem.newPwd1) {
  162. uni.showToast({
  163. title: '请输入新密码',
  164. icon: 'none'
  165. })
  166. return
  167. }
  168. if (!this.formItem.newPwd2) {
  169. uni.showToast({
  170. title: '请确认新密码',
  171. icon: 'none'
  172. })
  173. return
  174. }
  175. if (this.formItem.newPwd1 != this.formItem.newPwd2) {
  176. uni.showToast({
  177. title: '两次新密码不一致',
  178. icon: 'none'
  179. })
  180. return
  181. }
  182. uni.showLoading({
  183. title: '加载中'
  184. })
  185. var dateStr = (new Date()).getTime();
  186. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  187. this.requst({
  188. url: this.updatePwdUrl,
  189. data: {
  190. timestamp: dateStr,
  191. sign: sign,
  192. storeId: this.storeInfo.storeId,
  193. storeUserId: this.storeInfo.storeUserId,
  194. oldPwd: this.formItem.oldPwd,
  195. newPwd: this.formItem.newPwd1
  196. },
  197. success: res => {
  198. if (res.data.rtnBean.rtnCode == 0) {
  199. this.formVisible = false
  200. this.formItem = {
  201. storeUserId: '',
  202. userName: '',
  203. tel: ''
  204. }
  205. } else {
  206. if (res.data.rtnBean.rtnMsg != '') {
  207. this.$api.msg(res.data.rtnBean.rtnMsg);
  208. return;
  209. }
  210. }
  211. uni.hideLoading()
  212. },
  213. fail: (e) => {
  214. console.log("接口调用失败:" + JSON.stringify(e));
  215. uni.hideLoading()
  216. }
  217. })
  218. },
  219. cancelUpdate () {
  220. this.formVisible = false;
  221. this.formItem = {}
  222. },
  223. /**
  224. * 确认退出
  225. * 清除缓存重新登录
  226. */
  227. confirm() {
  228. // this.quitShow = false
  229. // uni.removeStorageSync('riderInfo')
  230. // console.log('111 :>> ', 111);
  231. uni.clearStorage()
  232. uni.reLaunch({
  233. url: '/pages/login/login'
  234. });
  235. }
  236. },
  237. onLoad () {
  238. this.getStoreAutoGo();
  239. }
  240. }
  241. </script>
  242. <style lang="scss" scoped>
  243. .setting-page {
  244. width: 100vw;
  245. height: 100vh;
  246. background-color: #f5f5f5;
  247. }
  248. .scroll-content {
  249. height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
  250. height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
  251. }
  252. .cell {
  253. width: 100%;
  254. height: 100rpx;
  255. background-color: #fff;
  256. padding: 0 20rpx;
  257. box-sizing: border-box;
  258. @include between;
  259. border-top: 2rpx solid #ececec;
  260. .label {
  261. width: 200rpx;
  262. }
  263. .value {
  264. flex: 1;
  265. @include flexEnd;
  266. }
  267. }
  268. .footer-btn {
  269. width: 100vw;
  270. margin-top: 40rpx;
  271. @include flexCenter;
  272. .logout {
  273. width: 80%;
  274. height: 80rpx;
  275. border-radius: 40rpx;
  276. background-color: $theme-color;
  277. color: #fff;
  278. @include flexCenter;
  279. }
  280. }
  281. .container {
  282. .name {
  283. margin: 40rpx 0;
  284. border: 2rpx solid #ececec;
  285. border-radius: 6rpx;
  286. }
  287. }
  288. </style>