warehouse.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view>
  3. <view class="head">
  4. <view class="header-wrap">
  5. <view class="index-header">
  6. <uni-icons class="fanhui" custom-prefix="iconfont" type="icon-fanhui"
  7. @click="leftClick"></uni-icons>
  8. <view class="input-wrap">
  9. <text class="iconfont">选择仓库</text>
  10. </view>
  11. <view class="map-wrap"></view>
  12. </view>
  13. </view>
  14. <view class="blank"></view>
  15. </view>
  16. <view class="uni-padding-wrap uni-common-mt">
  17. <view class="button-sp-area">
  18. <br><br><br><br>
  19. <button type="primary" @click="oneStock()" class="button btn">一期库[西]</button>
  20. <br><br><br><br>
  21. <button type="success" @click="twoStock()" class="button btn">二期库[东]</button>
  22. <br><br>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { storage } from '../../store/storgae.js';
  29. export default {
  30. data() {
  31. return {
  32. optType: "",
  33. title: 'button',
  34. loading: false,
  35. timer: null, // 定时器
  36. }
  37. },
  38. onLoad(options) {
  39. this.timer = null; // 修正变量名(原_this改为this)
  40. this.optType = options.optType || "";
  41. },
  42. onShow() {},
  43. onUnload() {
  44. this.clearTimer();
  45. this.loading = false;
  46. },
  47. methods: {
  48. openTypeError(error) {
  49. console.error('open-type error:', error);
  50. },
  51. clearTimer() {
  52. if (this.timer != null) {
  53. clearTimeout(this.timer);
  54. this.timer = null; // 清空定时器变量
  55. }
  56. },
  57. leftClick() {
  58. setTimeout(() => {
  59. uni.navigateBack();
  60. }, 30);
  61. },
  62. async oneStock() {
  63. storage.removeItem('reqWarehouseId');
  64. let $url = "";
  65. // 4. 用 this 代替全局 _this,更安全
  66. switch (this.optType) {
  67. case "group":
  68. $url = "/pages/sample/group";
  69. break;
  70. case "out":
  71. $url = "/pages/sample/sorting_out";
  72. break;
  73. case "task":
  74. $url = "/pages/sample/task";
  75. break;
  76. case "port":
  77. $url = "/pages/sample/port";
  78. break;
  79. case "stocktaking":
  80. $url = "/pages/sample/stocktaking";
  81. break;
  82. }
  83. const isSuccess = await storage.setItem('reqWarehouseId', "JINING-LIPAI");
  84. if (isSuccess) {
  85. const warehouseId = storage.getItem('reqWarehouseId');
  86. setTimeout(() => {
  87. uni.vibrateShort();
  88. uni.navigateTo({ url: $url });
  89. }, 500);
  90. }
  91. },
  92. async twoStock() {
  93. storage.removeItem('reqWarehouseId');
  94. let $url = "";
  95. switch (this.optType) {
  96. case "group":
  97. $url = "/pages/sample/group";
  98. break;
  99. case "out":
  100. $url = "/pages/sample/sorting_out";
  101. break;
  102. case "task":
  103. $url = "/pages/sample/task";
  104. break;
  105. case "port":
  106. $url = "/pages/sample/port";
  107. break;
  108. case "stocktaking":
  109. $url = "/pages/sample/stocktaking";
  110. break;
  111. }
  112. const isSuccess = await storage.setItem('reqWarehouseId', "JINING-LIPAI2");
  113. if (isSuccess) {
  114. const warehouseId = storage.getItem('reqWarehouseId');
  115. setTimeout(() => {
  116. uni.vibrateShort();
  117. uni.navigateTo({ url: $url });
  118. }, 500);
  119. }
  120. },
  121. isEmpty(obj) {
  122. return typeof obj === 'undefined' || obj == null || obj === "" || obj === "000000000000000000000000" || obj.length === 0;
  123. }
  124. }
  125. }
  126. </script>
  127. <style>
  128. button {
  129. margin-top: 30rpx;
  130. margin-bottom: 30rpx;
  131. }
  132. .button-sp-area {
  133. margin: 0 auto;
  134. width: 60%;
  135. }
  136. .mini-btn {
  137. margin-right: 10rpx;
  138. }
  139. .button {
  140. background-color: #4CAF50;
  141. color: white;
  142. text-align: center;
  143. border-radius: 6px;
  144. box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  145. transition: all 0.3s ease;
  146. }
  147. .button:hover {
  148. transform: scale(1.1);
  149. }
  150. </style>
  151. <style lang="scss">
  152. $color-base: #0039a6;
  153. $words-color-base: #333333;
  154. $words-color-light: #999999;
  155. .header-wrap {
  156. width: 100%;
  157. position: fixed;
  158. top: 0;
  159. z-index: 999;
  160. .index-header {
  161. height: 88upx;
  162. line-height: 88upx;
  163. padding: 0 30upx;
  164. padding-top: 40upx;
  165. background-color: $color-base;
  166. font-Size: 28upx;
  167. color: #fff;
  168. display: flex;
  169. align-items: center;
  170. justify-content: space-between;
  171. .fanhui {
  172. color: #fff !important;
  173. font-size: 28px;
  174. padding-top: 5px;
  175. font-weight: 700;
  176. }
  177. .lanya {
  178. color: #fff !important;
  179. font-size: 28px;
  180. padding-top: 5px;
  181. }
  182. .map-wrap {
  183. padding-top: 5px;
  184. }
  185. }
  186. }
  187. .blank {
  188. height: 126upx;
  189. }
  190. .btn {
  191. border-radius: 60%;
  192. width: 125px;
  193. height: 125px;
  194. margin: auto;
  195. text-align: center;
  196. line-height: 125px;
  197. border-color: #0039a6;
  198. font-size: 20px;
  199. }
  200. </style>