bulade-ui 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,7 +98,6 @@ var app = getApp();
98
98
  var deviceInfo = app.globalData.deviceInfo;
99
99
  var systemInfo = app.globalData.systemInfo;
100
100
  var menuButtonInfo = app.globalData.menuButtonDistance;
101
-
102
101
  var screenWidth = systemInfo.screenWidth;
103
102
 
104
103
  var statusBarHeight = systemInfo.statusBarHeight;
@@ -127,10 +126,15 @@ Component({
127
126
  showShare: {
128
127
  type: Boolean,
129
128
  value: false
129
+ },
130
+ textAlign: {
131
+ type: String,
132
+ value: "left"
130
133
  }
131
134
  },
132
135
  data: {
133
- style: _baseStyle.join(";")
136
+ style: _baseStyle.join(";"),
137
+ titleStyle: ""
134
138
  },
135
139
  lifetimes: {
136
140
  ready: function ready() {
@@ -153,12 +157,35 @@ Component({
153
157
  style: _baseStyle.join(";")
154
158
  });
155
159
  }
160
+ },
161
+
162
+ goBack: function goBack(_goBack) {
163
+ var _this = this;
164
+
165
+ if (this.data.textAlign == "left") {
166
+ this.setData({
167
+ titleStyle: "justify-content: flex-start; padding-left: " + (12 - padding) * 2 + "rpx;"
168
+ });
169
+ return;
170
+ }
171
+
172
+ if (_goBack) {
173
+ this.createSelectorQuery().select(".operations").boundingClientRect(function (res) {
174
+ _this.setData({
175
+ titleStyle: "padding-left: " + (menuButtonInfo.width - padding - res.height) * 2 + "rpx"
176
+ });
177
+ }).exec();
178
+ } else {
179
+ this.setData({
180
+ titleStyle: "padding-left: " + (menuButtonInfo.width - padding) * 2 + "rpx"
181
+ });
182
+ }
156
183
  }
157
184
  },
158
185
  methods: {
159
186
  navigateHome: function navigateHome() {
160
187
  wx.switchTab({
161
- url: "/pages/main/index"
188
+ url: "/pages/home/index"
162
189
  });
163
190
  },
164
191
  navigateBack: function navigateBack() {
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/bld-nav-bar/index.js"],"names":["app","getApp","deviceInfo","globalData","systemInfo","menuButtonInfo","menuButtonDistance","screenWidth","statusBarHeight","gap","top","padding","right","_baseStyle","height","width","Component","externalClasses","options","multipleSlots","properties","bgColor","type","String","goBack","Boolean","value","showTitle","showShare","data","style","join","lifetimes","ready","totalHeight","triggerEvent","observers","_style","push","setData","methods","navigateHome","wx","switchTab","url","navigateBack","pages","getCurrentPages","length"],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;AClFA,IAAMA,MAAMC,QAAZ;;AAEA,IAAMC,aAAaF,IAAIG,UAAJ,CAAeD,UAAlC;AACA,IAAME,aAAaJ,IAAIG,UAAJ,CAAeC,UAAlC;AACA,IAAMC,iBAAiBL,IAAIG,UAAJ,CAAeG,kBAAtC;;AAEA,IAAMC,cAAcH,WAAWG,WAA/B;;AAEA,IAAMC,kBAAkBJ,WAAWI,eAAnC;AACA,IAAMC,MAAMJ,eAAeK,GAAf,GAAqBF,eAAjC;AACA,IAAMG,UAAUJ,cAAcF,eAAeO,KAA7C;;AAEA,IAAMC,aAAa,mBACDR,eAAeK,GADd,8BAEED,GAFF,2BAGDJ,eAAeS,MAHd,sBAINT,eA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AAEA;AACD;;AAED,WAAKJ,YAAL;AACD;AAjBM;AAhDD,CAAV,E","file":"bld-nav-bar/index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 17);\n","const app = getApp();\n\nconst deviceInfo = app.globalData.deviceInfo;\nconst systemInfo = app.globalData.systemInfo;\nconst menuButtonInfo = app.globalData.menuButtonDistance;\n\nconst screenWidth = systemInfo.screenWidth;\n\nconst statusBarHeight = systemInfo.statusBarHeight;\nconst gap = menuButtonInfo.top - statusBarHeight;\nconst padding = screenWidth - menuButtonInfo.right;\n\nconst _baseStyle = [\n `padding-top: ${menuButtonInfo.top}px`,\n `padding-bottom: ${gap}px`,\n `line-height: ${menuButtonInfo.height}px`,\n `height: ${menuButtonInfo.height}px`,\n `padding-left: ${padding}px`,\n `padding-right: ${padding * 2 + menuButtonInfo.width}px`,\n `width: calc(100% - ${3 * padding + menuButtonInfo.width}px)`,\n];\n\nComponent({\n externalClasses: [\"iclass\"],\n options: {\n multipleSlots: true, // 在组件定义时的选项中启用多slot支持\n },\n properties: {\n bgColor: {\n type: String,\n },\n goBack: {\n type: Boolean,\n value: false,\n },\n showTitle: {\n type: Boolean,\n value: true,\n },\n showShare: {\n type: Boolean,\n value: false,\n },\n },\n data: {\n style: _baseStyle.join(\";\"),\n },\n lifetimes: {\n ready() {\n const totalHeight = menuButtonInfo.top + menuButtonInfo.height + gap;\n\n this.triggerEvent(\"height-change\", totalHeight);\n },\n },\n observers: {\n bgColor: function (bgColor) {\n if (bgColor) {\n const _style = [..._baseStyle];\n\n _style.push(`background-color: ${bgColor}`);\n this.setData({\n style: _style.join(\";\"),\n });\n } else {\n this.setData({\n style: _baseStyle.join(\";\"),\n });\n }\n },\n },\n methods: {\n navigateHome() {\n wx.switchTab({\n url: \"/pages/main/index\",\n });\n },\n\n navigateBack() {\n const pages = getCurrentPages();\n\n if (pages.length > 1) {\n wx.navigateBack();\n\n return;\n }\n\n this.navigateHome();\n },\n },\n});\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/bld-nav-bar/index.js"],"names":["app","getApp","deviceInfo","globalData","systemInfo","menuButtonInfo","menuButtonDistance","screenWidth","statusBarHeight","gap","top","padding","right","_baseStyle","height","width","Component","externalClasses","options","multipleSlots","properties","bgColor","type","String","goBack","Boolean","value","showTitle","showShare","textAlign","data","style","join","titleStyle","lifetimes","ready","totalHeight","triggerEvent","observers","_style","push","setData","createSelectorQuery","select","boundingClientRect","res","exec","methods","navigateHome","wx","switchTab","url","navigateBack","pages","getCurrentPages","length"],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;AClFA,IAAMA,MAAMC,Q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;AACX,YAAMkB,mBAAa1B,UAAb,CAAN;;AAEA0B,eAAOC,IAAP,wBAAiCnB,QAAjC;AACA,aAAKoB,OAAL,CAAa;AACXV,iBAAOQ,OAAOP,IAAP,CAAY,GAAZ;AADI,SAAb;AAGD,OAPD,MAOO;AACL,aAAKS,OAAL,CAAa;AACXV,iBAAOlB,WAAWmB,IAAX,CAAgB,GAAhB;AADI,SAAb;AAGD;AACF,KAdQ;;AAgBTR,YAAQ,gBAAUA,OAAV,EAAkB;AAAA;;AACxB,UAAI,KAAKM,IAAL,CAAUD,SAAV,IAAuB,MAA3B,EAAmC;AACjC,aAAKY,OAAL,CAAa;AACXR,sEAA0D,CAAC,KAAKtB,OAAN,IAAiB,CAA3E;AADW,SAAb;AAGA;AACD;;AAED,UAAIa,OAAJ,EAAY;AACV,aAAKkB,mBAAL,GACGC,MADH,CACU,aADV,EAEGC,kBAFH,CAEsB,UAACC,GAAD,EAAS;AAC3B,gBAAKJ,OAAL,CAAa;AACXR,2CAA6B,CAAC5B,eAAeU,KAAf,GAAuBJ,OAAvB,GAAiCkC,IAAI/B,MAAtC,IAAgD,CAA7E;AADW,WAAb;AAGD,SANH,EAOGgC,IAPH;AAQD,OATD,MASO;AACL,aAAKL,OAAL,CAAa;AACXR,yCAA6B,CAAC5B,eAAeU,KAAf,GAAuBJ,OAAxB,IAAmC,CAAhE;AADW,SAAb;AAGD;AACF;AAtCQ,GArCH;AA6ERoC,WAAS;AACPC,gBADO,0BACQ;AACbC,SAAGC,SAAH,CAAa;AACXC,aAAK;AADM,OAAb;AAGD,KALM;AAOPC,gBAPO,0BAOQ;AACb,UAAMC,QAAQC,iBAAd;;AAEA,UAAID,MAAME,MAAN,GAAe,CAAnB,EAAsB;AACpBN,WAAGG,YAAH;;AAEA;AACD;;AAED,WAAKJ,YAAL;AACD;AAjBM;AA7ED,CAAV,E","file":"bld-nav-bar/index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 17);\n","const app = getApp();\n\nconst deviceInfo = app.globalData.deviceInfo;\nconst systemInfo = app.globalData.systemInfo;\nconst menuButtonInfo = app.globalData.menuButtonDistance;\nconst screenWidth = systemInfo.screenWidth;\n\nconst statusBarHeight = systemInfo.statusBarHeight;\nconst gap = menuButtonInfo.top - statusBarHeight;\nconst padding = screenWidth - menuButtonInfo.right;\n\nconst _baseStyle = [\n `padding-top: ${menuButtonInfo.top}px`,\n `padding-bottom: ${gap}px`,\n `line-height: ${menuButtonInfo.height}px`,\n `height: ${menuButtonInfo.height}px`,\n `padding-left: ${padding}px`,\n `padding-right: ${padding * 2 + menuButtonInfo.width}px`,\n `width: calc(100% - ${3 * padding + menuButtonInfo.width}px)`,\n];\n\nComponent({\n externalClasses: [\"iclass\"],\n options: {\n multipleSlots: true, // 在组件定义时的选项中启用多slot支持\n },\n properties: {\n bgColor: {\n type: String,\n },\n goBack: {\n type: Boolean,\n value: false,\n },\n showTitle: {\n type: Boolean,\n value: true,\n },\n showShare: {\n type: Boolean,\n value: false,\n },\n textAlign: {\n type: String,\n value: \"left\",\n },\n },\n data: {\n style: _baseStyle.join(\";\"),\n titleStyle: \"\",\n },\n lifetimes: {\n ready() {\n const totalHeight = menuButtonInfo.top + menuButtonInfo.height + gap;\n\n this.triggerEvent(\"height-change\", totalHeight);\n },\n },\n observers: {\n bgColor: function (bgColor) {\n if (bgColor) {\n const _style = [..._baseStyle];\n\n _style.push(`background-color: ${bgColor}`);\n this.setData({\n style: _style.join(\";\"),\n });\n } else {\n this.setData({\n style: _baseStyle.join(\";\"),\n });\n }\n },\n\n goBack: function (goBack) {\n if (this.data.textAlign == \"left\") {\n this.setData({\n titleStyle: `justify-content: flex-start; padding-left: ${(12 - padding) * 2}rpx;`,\n });\n return;\n }\n\n if (goBack) {\n this.createSelectorQuery()\n .select(\".operations\")\n .boundingClientRect((res) => {\n this.setData({\n titleStyle: `padding-left: ${(menuButtonInfo.width - padding - res.height) * 2}rpx`,\n });\n })\n .exec();\n } else {\n this.setData({\n titleStyle: `padding-left: ${(menuButtonInfo.width - padding) * 2}rpx`,\n });\n }\n },\n },\n methods: {\n navigateHome() {\n wx.switchTab({\n url: \"/pages/home/index\",\n });\n },\n\n navigateBack() {\n const pages = getCurrentPages();\n\n if (pages.length > 1) {\n wx.navigateBack();\n\n return;\n }\n\n this.navigateHome();\n },\n },\n});\n"],"sourceRoot":""}
@@ -11,7 +11,12 @@
11
11
  <bld-icon name="backward" />
12
12
  </view>
13
13
  </view>
14
- <view class="title"> <slot wx:if="{{ showTitle }}" /> </view>
14
+ <view
15
+ class="title"
16
+ style="{{ titleStyle }}"
17
+ >
18
+ <slot wx:if="{{ showTitle }}" />
19
+ </view>
15
20
  <view class="operations right">
16
21
  <button
17
22
  wx:if="{{ showShare }}"
@@ -13,7 +13,7 @@
13
13
  .title {
14
14
  flex: 1;
15
15
  display: flex;
16
- justify-content: flex-start;
16
+ justify-content: center;
17
17
  align-items: center;
18
18
  }
19
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulade-ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "轻量、可靠的小程序 UI 组件库",
5
5
  "main": "miniprogram_dist/index.js",
6
6
  "scripts": {
@@ -3,7 +3,6 @@ const app = getApp();
3
3
  const deviceInfo = app.globalData.deviceInfo;
4
4
  const systemInfo = app.globalData.systemInfo;
5
5
  const menuButtonInfo = app.globalData.menuButtonDistance;
6
-
7
6
  const screenWidth = systemInfo.screenWidth;
8
7
 
9
8
  const statusBarHeight = systemInfo.statusBarHeight;
@@ -41,9 +40,14 @@ Component({
41
40
  type: Boolean,
42
41
  value: false,
43
42
  },
43
+ textAlign: {
44
+ type: String,
45
+ value: "left",
46
+ },
44
47
  },
45
48
  data: {
46
49
  style: _baseStyle.join(";"),
50
+ titleStyle: "",
47
51
  },
48
52
  lifetimes: {
49
53
  ready() {
@@ -67,11 +71,35 @@ Component({
67
71
  });
68
72
  }
69
73
  },
74
+
75
+ goBack: function (goBack) {
76
+ if (this.data.textAlign == "left") {
77
+ this.setData({
78
+ titleStyle: `justify-content: flex-start; padding-left: ${(12 - padding) * 2}rpx;`,
79
+ });
80
+ return;
81
+ }
82
+
83
+ if (goBack) {
84
+ this.createSelectorQuery()
85
+ .select(".operations")
86
+ .boundingClientRect((res) => {
87
+ this.setData({
88
+ titleStyle: `padding-left: ${(menuButtonInfo.width - padding - res.height) * 2}rpx`,
89
+ });
90
+ })
91
+ .exec();
92
+ } else {
93
+ this.setData({
94
+ titleStyle: `padding-left: ${(menuButtonInfo.width - padding) * 2}rpx`,
95
+ });
96
+ }
97
+ },
70
98
  },
71
99
  methods: {
72
100
  navigateHome() {
73
101
  wx.switchTab({
74
- url: "/pages/main/index",
102
+ url: "/pages/home/index",
75
103
  });
76
104
  },
77
105
 
@@ -13,7 +13,7 @@
13
13
  .title {
14
14
  flex: 1;
15
15
  display: flex;
16
- justify-content: flex-start;
16
+ justify-content: center;
17
17
  align-items: center;
18
18
  }
19
19
 
@@ -37,4 +37,4 @@
37
37
  margin-left: 12rpx;
38
38
  }
39
39
  }
40
- }
40
+ }
@@ -11,7 +11,12 @@
11
11
  <bld-icon name="backward" />
12
12
  </view>
13
13
  </view>
14
- <view class="title"> <slot wx:if="{{ showTitle }}" /> </view>
14
+ <view
15
+ class="title"
16
+ style="{{ titleStyle }}"
17
+ >
18
+ <slot wx:if="{{ showTitle }}" />
19
+ </view>
15
20
  <view class="operations right">
16
21
  <button
17
22
  wx:if="{{ showShare }}"
@@ -13,7 +13,7 @@
13
13
  .title {
14
14
  flex: 1;
15
15
  display: flex;
16
- justify-content: flex-start;
16
+ justify-content: center;
17
17
  align-items: center;
18
18
  }
19
19
 
@@ -0,0 +1,90 @@
1
+ const app = getApp();
2
+
3
+ const deviceInfo = app.globalData.deviceInfo;
4
+ const systemInfo = app.globalData.systemInfo;
5
+ const menuButtonInfo = app.globalData.menuButtonDistance;
6
+
7
+ const screenWidth = systemInfo.screenWidth;
8
+
9
+ const statusBarHeight = systemInfo.statusBarHeight;
10
+ const gap = menuButtonInfo.top - statusBarHeight;
11
+ const padding = screenWidth - menuButtonInfo.right;
12
+
13
+ const _baseStyle = [
14
+ `padding-top: ${menuButtonInfo.top}px`,
15
+ `padding-bottom: ${gap}px`,
16
+ `line-height: ${menuButtonInfo.height}px`,
17
+ `height: ${menuButtonInfo.height}px`,
18
+ `padding-left: ${padding}px`,
19
+ `padding-right: ${padding * 2 + menuButtonInfo.width}px`,
20
+ `width: calc(100% - ${3 * padding + menuButtonInfo.width}px)`,
21
+ ];
22
+
23
+ Component({
24
+ externalClasses: ["iclass"],
25
+ options: {
26
+ multipleSlots: true, // 在组件定义时的选项中启用多slot支持
27
+ },
28
+ properties: {
29
+ bgColor: {
30
+ type: String,
31
+ },
32
+ goBack: {
33
+ type: Boolean,
34
+ value: false,
35
+ },
36
+ showTitle: {
37
+ type: Boolean,
38
+ value: true,
39
+ },
40
+ showShare: {
41
+ type: Boolean,
42
+ value: false,
43
+ },
44
+ },
45
+ data: {
46
+ style: _baseStyle.join(";"),
47
+ },
48
+ lifetimes: {
49
+ ready() {
50
+ const totalHeight = menuButtonInfo.top + menuButtonInfo.height + gap;
51
+
52
+ this.triggerEvent("height-change", totalHeight);
53
+ },
54
+ },
55
+ observers: {
56
+ bgColor: function (bgColor) {
57
+ if (bgColor) {
58
+ const _style = [..._baseStyle];
59
+
60
+ _style.push(`background-color: ${bgColor}`);
61
+ this.setData({
62
+ style: _style.join(";"),
63
+ });
64
+ } else {
65
+ this.setData({
66
+ style: _baseStyle.join(";"),
67
+ });
68
+ }
69
+ },
70
+ },
71
+ methods: {
72
+ navigateHome() {
73
+ wx.switchTab({
74
+ url: "/pages/main/index",
75
+ });
76
+ },
77
+
78
+ navigateBack() {
79
+ const pages = getCurrentPages();
80
+
81
+ if (pages.length > 1) {
82
+ wx.navigateBack();
83
+
84
+ return;
85
+ }
86
+
87
+ this.navigateHome();
88
+ },
89
+ },
90
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "bld-icon": "../bld-icon/index"
5
+ }
6
+ }
@@ -0,0 +1,40 @@
1
+ .nav-bar {
2
+ font-size: var(--font-size-lg);
3
+ font-weight: 500;
4
+ display: flex;
5
+ justify-content: flex-start;
6
+ align-items: center;
7
+ position: fixed;
8
+ left: 0;
9
+ top: 0;
10
+ z-index: 1000;
11
+ }
12
+
13
+ .title {
14
+ flex: 1;
15
+ display: flex;
16
+ justify-content: flex-start;
17
+ align-items: center;
18
+ }
19
+
20
+ .operation {
21
+ background: rgba(255, 255, 255, 0.6);
22
+ border: 1rpx solid rgba(0, 0, 0, 0.1);
23
+ border-radius: 32rpx;
24
+ width: 60rpx;
25
+ height: 60rpx;
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ margin-right: 12rpx;
30
+ padding: 0;
31
+ }
32
+
33
+ .operations {
34
+ &.right {
35
+ .operation {
36
+ margin-right: 0;
37
+ margin-left: 12rpx;
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,24 @@
1
+ <view
2
+ class="iclass nav-bar"
3
+ style="{{ style }}"
4
+ >
5
+ <view class="operations">
6
+ <view
7
+ wx:if="{{ goBack }}"
8
+ class="operation"
9
+ bind:tap="navigateBack"
10
+ >
11
+ <bld-icon name="backward" />
12
+ </view>
13
+ </view>
14
+ <view class="title"> <slot wx:if="{{ showTitle }}" /> </view>
15
+ <view class="operations right">
16
+ <button
17
+ wx:if="{{ showShare }}"
18
+ class="operation"
19
+ open-type="share"
20
+ >
21
+ <bld-icon name="share" />
22
+ </button>
23
+ </view>
24
+ </view>
@@ -0,0 +1,36 @@
1
+ .nav-bar {
2
+ font-size: var(--font-size-lg);
3
+ font-weight: 500;
4
+ display: flex;
5
+ justify-content: flex-start;
6
+ align-items: center;
7
+ position: fixed;
8
+ left: 0;
9
+ top: 0;
10
+ z-index: 1000;
11
+ }
12
+
13
+ .title {
14
+ flex: 1;
15
+ display: flex;
16
+ justify-content: flex-start;
17
+ align-items: center;
18
+ }
19
+
20
+ .operation {
21
+ background: rgba(255, 255, 255, 0.6);
22
+ border: 1rpx solid rgba(0, 0, 0, 0.1);
23
+ border-radius: 32rpx;
24
+ width: 60rpx;
25
+ height: 60rpx;
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ margin-right: 12rpx;
30
+ padding: 0;
31
+ }
32
+
33
+ .operations.right .operation {
34
+ margin-right: 0;
35
+ margin-left: 12rpx;
36
+ }